I am new to Jira Plugin Development. I have a need to access the FieldMetaBean of OrderableField and CustomField.
I am getting this fields through ComponentAccesor Can anyone help me with it?
Have found the Solution please find below
List<Project> extProjects = new ArrayList<Project>();
if(projectIds != null && !projectIds.isEmpty()) {
Long projectId = Long.parseLong(projectIds);
Project project = ComponentAccessor.getProjectManager().getProjectObj(projectId);
if(project != null) {
extProjects.add(project);
}
}else {
extProjects.addAll(ComponentAccessor.getProjectManager().getProjects());
}
JsonArray projJsonArray = new JsonArray();
if(extProjects != null && !extProjects.isEmpty()) {
for (int i = 0; i < extProjects.size(); i++) {
Project project = extProjects.get(i);
List<IssueType> issueTypes = new ArrayList<IssueType>();
issueTypes.addAll(project.getIssueTypes());
JsonObject projectJson = new JsonObject();
projectJson.addProperty("id", project.getId());
projectJson.addProperty("key", project.getKey());
projectJson.addProperty("name", project.getName());
JsonArray issueTypesJsonArray = new JsonArray();
for(IssueType issueType : issueTypes) {
JsonObject issueTypeJson = new JsonObject();
issueTypeJson.addProperty("id", issueType.getId());
issueTypeJson.addProperty("description", issueType.getDescription());
issueTypeJson.addProperty("name", issueType.getName());
issueTypeJson.addProperty("subtask", issueType.isSubTask());
issueTypeJson.addProperty("expand", "fields");
MutableIssue issuePattern = ComponentAccessor.getComponentOfType(IssueFactory.class).getIssue();
issuePattern.setProjectId(project.getId());
issuePattern.setIssueTypeId(issueType.getId());
IssueCreationHelperBean issueCreationHelperBean = ComponentAccessor.getComponentOfType(IssueCreationHelperBean.class);
FieldScreenRenderer fieldScreenRenderer = issueCreationHelperBean.createFieldScreenRenderer(issuePattern);
Map<String, FieldMetaBean> fieldsMap = getFieldMetadataBeans(issuePattern,issueType,project,fieldScreenRenderer);
Gson gson = new Gson();
issueTypeJson.add("fields", gson.toJsonTree(fieldsMap));
issueTypesJsonArray.add(issueTypeJson);
}
projectJson.add("issuetypes", issueTypesJsonArray);
projJsonArray.add(projectJson);
}
}
JsonObjectjsonObject = new JsonObject();
jsonObject.add("projects", projJsonArray);
jsonObject.addProperty("expand", "projects");
jsonObject.addProperty("total", Integer.valueOf(projJsonArray.size()));
return jsonObject;
Hello @Harshit Shihora , I am having the issue with FieldMetaBeans, any idea if the method has being modified. Thanks in advance!
Map<String, FieldMetaBean> fieldsMap = getFieldMetadataBeans(issuePattern,issueType,project,fieldScreenRenderer);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.