com.almworks.jira.structure.api.util.JiraFunc Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of structure-api Show documentation
Show all versions of structure-api Show documentation
Public API for the Structure Plugin for JIRA
package com.almworks.jira.structure.api.util;
import com.atlassian.crowd.embedded.api.Group;
import com.atlassian.jira.bc.EntityNotFoundException;
import com.atlassian.jira.bc.project.component.ProjectComponent;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueConstant;
import com.atlassian.jira.issue.customfields.CustomFieldType;
import com.atlassian.jira.issue.customfields.option.Option;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.Field;
import com.atlassian.jira.issue.issuetype.IssueType;
import com.atlassian.jira.issue.label.Label;
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.issue.link.IssueLinkType;
import com.atlassian.jira.issue.priority.Priority;
import com.atlassian.jira.issue.resolution.Resolution;
import com.atlassian.jira.issue.security.IssueSecurityLevel;
import com.atlassian.jira.issue.status.Status;
import com.atlassian.jira.issue.worklog.WorkRatio;
import com.atlassian.jira.permission.ProjectPermissions;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.project.ProjectConstant;
import com.atlassian.jira.project.version.Version;
import com.atlassian.jira.security.PermissionManager;
import com.atlassian.jira.security.plugin.ProjectPermissionKey;
import com.atlassian.jira.security.roles.ProjectRole;
import com.atlassian.jira.sharing.SharedEntity;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.util.JiraKeyUtils;
import com.atlassian.jira.workflow.JiraWorkflow;
import com.atlassian.plugin.ModuleDescriptor;
import org.ofbiz.core.entity.GenericValue;
import java.security.Principal;
import java.sql.Timestamp;
import java.util.*;
import static com.almworks.jira.structure.api.item.CoreIdentities.canonicalVersionName;
/**
* JiraFunc
contains Jira-related functions.
*
* @author Igor Sereda
*/
public class JiraFunc {
public static final La PROJECT_ID = new La(Long.class) {
@Override
public Long la(Project argument) {
return argument == null ? null : argument.getId();
}
};
public static final La PROJECT_NAME = new La() {
public String la(Project argument) {
return argument == null ? null : argument.getName();
}
};
public static final La PROJECT_KEY = new La(String.class) {
public String la(Project argument) {
return argument == null ? null : argument.getKey();
}
};
public static final La PROJECT_DESCRIPTION = new La(String.class) {
public String la(Project argument) {
return argument == null ? null : argument.getDescription();
}
};
public static final La ISSUE_ID = new La() {
@Override
public Long la(Issue argument) {
return argument == null ? null : argument.getId();
}
};
public static final La KEY_PROJECT = new La() {
public Project la(String key) {
if (key == null) return null;
return JiraComponents.getProjectManager().getProjectObjByKey(key);
}
};
public static final La ID_PROJECT = new La() {
public Project la(Long id) {
if (id == null) return null;
return JiraComponents.getProjectManager().getProjectObj(id);
}
};
public static final La ID_ISSUETYPE = new La() {
@Override
public IssueType la(String id) {
return id == null ? null : JiraComponents.getConstantsManager().getIssueType(id);
}
};
public static final La ID_STATUS = new La() {
@Override
public Status la(String id) {
return id == null ? null : JiraComponents.getConstantsManager().getStatus(id);
}
};
public static final La ID_PRIORITY = new La() {
@Override
public Priority la(String id) {
return id == null ? null : JiraComponents.getConstantsManager().getPriorityObject(id);
}
};
public static final La ID_RESOLUTION = new La() {
@Override
public Resolution la(String id) {
return id == null ? null : JiraComponents.getConstantsManager().getResolution(id);
}
};
public static final La ID_COMPONENT = new La() {
@Override
public ProjectComponent la(Long id) {
try {
return id == null ? null : JiraComponents.getProjectComponentManager().find(id);
} catch (EntityNotFoundException e) {
return null;
}
}
};
public static final La ID_VERSION = new La() {
@Override
public Version la(Long id) {
return id == null ? null : JiraComponents.getVersionManager().getVersion(id);
}
};
public static final La PROJECTROLE_ID = new La() {
public Long la(ProjectRole argument) {
return argument == null ? null : argument.getId();
}
};
public static final La PRINCIPAL_NAME = new La(String.class) {
public String la(Principal argument) {
return argument == null ? null : argument.getName();
}
};
public static final La GROUP_NAME = new La(String.class) {
public String la(Group argument) {
return argument == null ? null : argument.getName();
}
};
public static final La MODULE_COMPLETE_KEY = new La() {
public String la(ModuleDescriptor argument) {
return argument == null ? null : argument.getCompleteKey();
}
};
public static final La LINKTYPE_ID = new La() {
public Long la(IssueLinkType argument) {
return argument == null ? null : argument.getId();
}
};
public static final La SHAREDENTITY_ID = new La() {
public Long la(SharedEntity argument) {
return argument == null ? null : argument.getId();
}
};
public static final La CUSTOMFIELD_TYPE = new La() {
public CustomFieldType la(CustomField argument) {
return argument == null ? null : argument.getCustomFieldType();
}
};
public static final La CUSTOMFIELDTYPE_KEY = new La() {
public String la(CustomFieldType argument) {
return argument == null ? null : argument.getKey();
}
};
public static final La CUSTOMFIELD_ID = new La() {
public String la(CustomField argument) {
return argument == null ? null : argument.getId();
}
};
public static final La CUSTOMFIELD_LONG_ID = new La() {
public Long la(CustomField argument) {
return argument == null ? null : argument.getIdAsLong();
}
};
public static final La FIELD_NAME = new La(String.class) {
@Override
public String la(Field argument) {
return argument == null ? null : argument.getName();
}
};
public static final La ISSUETYPE_SUBTASK = new La() {
public Boolean la(IssueType argument) {
return argument != null && argument.isSubTask();
}
};
public static final La ISSUECONSTANT_ID = new La(String.class) {
public String la(IssueConstant argument) {
return argument == null ? null : argument.getId();
}
};
public static final La ISSUECONSTANT_NAME = new La(String.class) {
@Override
public String la(IssueConstant argument) {
return argument == null ? null : argument.getName();
}
};
public static final La ISSUECONSTANT_NAME_LOCAL = new La(String.class) {
public String la(IssueConstant argument) {
return argument == null ? null : argument.getNameTranslation();
}
};
public static final La ISSUECONSTANT_SEQUENCE = new La() {
@Override
public Long la(IssueConstant argument) {
return argument == null ? null : argument.getSequence();
}
};
public static final La NEGATED_ISSUECONSTANT_SEQUENCE = new La() {
@Override
public Long la(IssueConstant argument) {
return argument == null ? null : argument.getSequence() == null ? null : -argument.getSequence();
}
};
public static final La WORKFLOW_NAME = new La() {
public String la(JiraWorkflow argument) {
return argument == null ? null : argument.getName();
}
};
public static final La APPLICATION_USER_NAME = new La() {
public String la(ApplicationUser argument) {
return argument == null ? null : argument.getDisplayName();
}
};
public static final La USER_NAME = new La() {
public String la(ApplicationUser argument) {
return argument == null ? null : argument.getDisplayName();
}
};
public static final La USER_KEY = new La() {
public String la(ApplicationUser argument) {
return argument == null ? null : argument.getKey();
}
};
public static final La VERSION_ACTIVE = new La(Boolean.class) {
@Override
public Boolean la(Version argument) {
return argument == null ? null : !argument.isArchived();
}
};
public static final La VERSION_SEQUENCE = new La(Long.class) {
@Override
public Long la(Version argument) {
return argument == null ? null : argument.getSequence();
}
};
public static final La VERSION_PROJECT = new La(Project.class) {
@Override
public Project la(Version argument) {
return argument == null ? null : argument.getProject();
}
};
public static final La PROJECTCONSTANT_ID = new La(Long.class) {
@Override
public Long la(ProjectConstant argument) {
return argument == null ? null : argument.getId();
}
};
public static final La PROJECTCONSTANT_NAME = new La(String.class) {
@Override
public String la(ProjectConstant argument) {
return argument == null ? null : argument.getName();
}
};
public static final La PROJECTCONSTANT_DESCRIPTION = new La(String.class) {
@Override
public String la(ProjectConstant argument) {
return argument == null ? null : argument.getDescription();
}
};
public static final La PROJECTCONSTANT_PROJECTID = new La(Long.class) {
@Override
public Long la(ProjectConstant argument) {
return argument == null ? null : argument.getProjectId();
}
};
public static final La GENERICVALUE_LONG_ID = new La() {
public Long la(GenericValue argument) {
try {
return argument == null ? null : argument.getLong("id");
} catch (Exception e) {
return null;
}
}
};
public static final La GENERICVALUE_STRING_ID = new La() {
public String la(GenericValue argument) {
try {
return argument == null ? null : argument.getString("id");
} catch (Exception e) {
return null;
}
}
};
public static final La ISSUE_PROJECT = new La() {
public Project la(Issue argument) {
return argument == null ? null : argument.getProjectObject();
}
};
public static final La ISSUE_PROJECTID = new La(Long.class) {
@Override
public Long la(Issue argument) {
return argument == null ? null : argument.getProjectId();
}
};
public static final La ISSUE_ISSUETYPE = new La() {
public IssueType la(Issue argument) {
return argument == null ? null : argument.getIssueType();
}
};
public static final La ISSUETYPE_ID = new La() {
public String la(IssueType argument) {
return argument == null ? null : argument.getId();
}
};
public static final La ISSUETYPE_NAME = new La() {
public String la(IssueType argument) {
return argument == null ? null : argument.getNameTranslation();
}
};
public static final La ISSUE_PRIORITY = new La() {
public Priority la(Issue argument) {
return argument == null ? null : argument.getPriority();
}
};
public static final La ISSUE_STATUS = new La() {
@Override
public Status la(Issue argument) {
return argument == null ? null : argument.getStatus();
}
};
public static final La ISSUE_RESOLUTION = new La() {
@Override
public Resolution la(Issue argument) {
return argument == null ? null : argument.getResolution();
}
};
public static final La ISSUE_ISSUETYPEID = ISSUE_ISSUETYPE.supply(ISSUETYPE_ID);
public static final La ISSUE_PRIORITYID = ISSUE_PRIORITY.supply(ISSUECONSTANT_ID);
public static final La ISSUE_RESOLUTIONID = ISSUE_RESOLUTION.supply(ISSUECONSTANT_ID);
public static final La ISSUE_STATUSID = ISSUE_STATUS.supply(ISSUECONSTANT_ID);
public static final La ISSUE_SUMMARY = new La(String.class) {
@Override
public String la(Issue argument) {
return argument == null ? null : argument.getSummary();
}
};
public static final La ISSUE_DESCRIPTION = new La(String.class) {
@Override
public String la(Issue argument) {
return argument == null ? null : argument.getDescription();
}
};
public static final La ISSUE_ENVIRONMENT = new La(String.class) {
@Override
public String la(Issue argument) {
return argument == null ? null : argument.getEnvironment();
}
};
public static final La ISSUE_KEY = new La(String.class) {
@Override
public String la(Issue argument) {
return argument == null ? null : argument.getKey();
}
};
public static final La ISSUE_ORIGINAL_ESTIMATE = new La(Long.class) {
@Override
public Long la(Issue issue) {
return issue == null ? null : issue.getOriginalEstimate();
}
};
public static final La ISSUE_REMAINING_ESTIMATE = new La(Long.class) {
@Override
public Long la(Issue issue) {
return issue == null ? null : issue.getEstimate();
}
};
public static final La ISSUE_TIME_SPENT = new La(Long.class) {
@Override
public Long la(Issue issue) {
return issue == null ? null : issue.getTimeSpent();
}
};
public static final La ISSUE_TOTAL_TIME = new La(Long.class) {
@Override
public Long la(Issue issue) {
Long spent = issue == null ? null : issue.getTimeSpent();
Long remaining = issue == null ? null : issue.getEstimate();
Long total = NumericFunctions.longAddOrNull(spent, remaining);
return total != null && total > 0 ? total : null;
}
};
public static final La ISSUE_WORK_RATIO = new La() {
public Long la(Issue argument) {
return argument == null ? null : WorkRatio.getWorkRatio(argument);
}
};
public static final La ISSUE_VOTES = new La(Long.class) {
@Override
public Long la(Issue argument) {
return argument == null ? null : argument.getVotes();
}
};
public static final La ISSUE_WATCHES = new La(Long.class) {
@Override
public Long la(Issue argument) {
return argument == null ? null : argument.getWatches();
}
};
public static final La USERKEY_APPLICATIONUSER = new La(ApplicationUser.class) {
@Override
public ApplicationUser la(String argument) {
return JiraUsers.byKey(argument);
}
};
public static final La ISSUE_ASSIGNEEID = new La(String.class) {
@Override
public String la(Issue argument) {
return argument == null ? null : argument.getAssigneeId();
}
};
public static final La ISSUE_ASSIGNEE = USERKEY_APPLICATIONUSER.apply(ISSUE_ASSIGNEEID);
public static final La ISSUE_REPORTERID = new La(String.class) {
@Override
public String la(Issue argument) {
return argument == null ? null : argument.getReporterId();
}
};
public static final La ISSUE_REPORTER = USERKEY_APPLICATIONUSER.apply(ISSUE_REPORTERID);
public static final La ISSUE_CREATORID = new La(String.class) {
public String la(Issue argument) {
return argument == null ? null : argument.getCreatorId();
}
};
public static final La ISSUE_CREATOR = USERKEY_APPLICATIONUSER.apply(ISSUE_CREATORID);
public static final La ISSUE_CREATED = new La(Timestamp.class) {
@Override
public Timestamp la(Issue argument) {
return argument == null ? null : argument.getCreated();
}
};
public static final La ISSUE_UPDATED = new La(Timestamp.class) {
@Override
public Timestamp la(Issue argument) {
return argument == null ? null : argument.getUpdated();
}
};
public static final La ISSUE_DUE_DATE = new La(Timestamp.class) {
@Override
public Timestamp la(Issue argument) {
return argument == null ? null : argument.getDueDate();
}
};
public static final La ISSUE_RESOLUTION_DATE = new La(Timestamp.class) {
@Override
public Timestamp la(Issue argument) {
return argument == null ? null : argument.getResolutionDate();
}
};
public static final La> ISSUE_AFFECTED_VERSIONS = new La>() {
@Override
public Collection la(Issue argument) {
return argument == null ? null : argument.getAffectedVersions();
}
};
public static final La> ISSUE_FIX_VERSIONS = new La>() {
@Override
public Collection la(Issue argument) {
return argument == null ? null : argument.getFixVersions();
}
};
public static final La> ISSUE_COMPONENTS = new La>() {
@Override
public Collection la(Issue argument) {
return argument == null ? null : argument.getComponents();
}
};
public static final La> ISSUE_LABELS = new La>() {
@Override
public Set
© 2015 - 2024 Weber Informatics LLC | Privacy Policy