com.atlassian.jira.issue.Issue Java Examples

The following examples show how to use com.atlassian.jira.issue.Issue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroovioliValidator.java    From jira-groovioli with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void validate(Map transientVars, Map args, PropertySet ps) throws InvalidInputException {
    Issue issue = (Issue) transientVars.get("issue");
    String script = (String) args.get(FIELD);
    String message = (String) args.get(MESSAGE);
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("issue", issue);
    parameters.put("issueImpl", IssueImpl.class.cast(issue));
    parameters.put("transientVars", transientVars);
    parameters.put("args", args);
    parameters.put("ps", ps);
    parameters.put("log", log);

    try {
        if((Boolean) scriptManager.executeScript(script, parameters)==false)
            throw new InvalidInputException(message);
    } catch (ScriptException ex) {
        log.error("Error", ex);
        throw new InvalidInputException(ex);
    }
}
 
Example #2
Source File: GroovioliCondition.java    From jira-groovioli with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public boolean passesCondition(Map transientVars, Map args, PropertySet ps) throws WorkflowException {
    Issue issue = getIssue(transientVars);
    String script = (String) args.get(GroovioliFunctionFactory.FIELD);

    Map<String, Object> parameters = new HashMap<>();
    parameters.put("issue", issue);
    parameters.put("issueImpl", IssueImpl.class.cast(issue));
    parameters.put("transientVars", transientVars);
    parameters.put("args", args);
    parameters.put("ps", ps);
    parameters.put("log", log);

    try {
        return (Boolean) scriptManager.executeScript(script, parameters);
    } catch (Exception ex) {
        log.error("Error", ex);
        throw new WorkflowException(ex);
    }
}
 
Example #3
Source File: PlanningPokerPanel.java    From planning-poker-plugin with MIT License 6 votes vote down vote up
@Override
public String getHtml(Map<String, Object> context) {
    if (!authContext.isLoggedInUser()) {
        return "You must be logged in to view planning poker session.";
    }

    String issueKey = ((Issue) context.get("issue")).getKey();
    Session session = sessionService.get(issueKey);
    if (session == null) {
        return "No session.";
    }

    context.put("session", session);
    context.put("pokerComponent", this);
    String baseurl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL);
    context.put("baseurl", baseurl);

    StringWriter stringWriter = new StringWriter();
    try {
        templateRenderer.render("views/panel.vm", context, stringWriter);
    } catch (IOException e) {
        log.error("Failed to render Planning Poker panel, exception message: {}", e.getMessage());
        return null;
    }
    return stringWriter.toString();
}
 
Example #4
Source File: SessionService.java    From planning-poker-plugin with MIT License 6 votes vote down vote up
public Session get(String issueKey) {
    log.info("Get session by issue key: " + issueKey);
    Issue issue = issueService.getIssue(authContext.getUser().getDirectoryUser(), issueKey).getIssue();
    Properties sessionProps = (Properties) pluginSettings.get(getIssueStoreKey(issue));
    if (sessionProps == null) {
        return null;
    }

    Session session = new Session();
    session.setCreated(new Date(Long.parseLong(sessionProps.getProperty("created"))));
    session.setStart(new Date(Long.parseLong(sessionProps.getProperty("start"))));
    session.setEnd(new Date(Long.parseLong(sessionProps.getProperty("end"))));
    session.setIssue(issue);
    session.setAuthor(userManager.getUserByKey(sessionProps.getProperty("authorKey")));

    return session;
}
 
Example #5
Source File: MetricListener.java    From jira-prometheus-exporter with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@EventListener
public void onIssueEvent(IssueEvent issueEvent) {
    Issue issue = issueEvent.getIssue();
    if (issue != null) {
        String eventType = "";
        try {
            eventType = eventTypeManager.getEventType(issueEvent.getEventTypeId()).getName();
        } catch (IllegalArgumentException e) {
        }
        eventTypeManager.getEventType(issueEvent.getEventTypeId());
        metricCollector.issueUpdateCounter(issue.getProjectObject().getKey(), eventType, getCurrentUser());
    }
}
 
Example #6
Source File: MetricListener.java    From jira-prometheus-exporter with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@EventListener
public void onIssueViewEvent(IssueViewEvent issueViewEvent) {
    Issue issue = issueManager.getIssueObject(issueViewEvent.getId());
    if (issue != null) {
        metricCollector.issueViewCounter(issue.getProjectObject().getKey(), getCurrentUser());
    }
}
 
Example #7
Source File: ScriptReadOnlyViewFieldConfig.java    From jira-groovioli with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Object getConfigurationObject(Issue issue, FieldConfig fieldConfig) {
    Map<String, String> configObject = new HashMap<>();
    configObject.put("viewTemplate", fieldDataManager.getReadOnlyScriptView(fieldConfig));
    configObject.put("columnTemplate", fieldDataManager.getReadOnlyScriptColumn(fieldConfig));
    return configObject;
}
 
Example #8
Source File: SessionAction.java    From planning-poker-plugin with MIT License 5 votes vote down vote up
@Override
public String doDefault() throws Exception {

    if (!authContext.isLoggedInUser()) {
        addErrorMessage("You must be logged in to be able to create new session.");
        return ERROR;
    }

    Issue issue = getIssueObject();
    if (issue == null) {
        return ERROR;
    }

    Session session = sessionService.get(issue.getKey());
    if (session != null) {
        if (sessionService.getStatus(session) != Status.FINISHED) {
            addErrorMessage("There already is a created session that hasn't finished yet. " +
                    "Ask the owner to delete it or wait until current session ends.");
            return ERROR;
        }

        addMessage("There is already a poker session created. " +
                "Creating a new session will delete the old one with all its data (votes).");
    }

    return INPUT;
}
 
Example #9
Source File: SessionAction.java    From planning-poker-plugin with MIT License 5 votes vote down vote up
private Issue getIssueObject() {
    IssueService.IssueResult issueResult = issueService.getIssue(getCurrentUser().getDirectoryUser(), getKey());
    if (!issueResult.isValid()) {
        this.addErrorCollection(issueResult.getErrorCollection());
        return null;
    }

    return issueResult.getIssue();
}
 
Example #10
Source File: ScriptReadOnlyViewField.java    From jira-groovioli with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Nullable
@Override
public String getValueFromIssue(CustomField customField, Issue issue) {
    return "Ferfe";
}
 
Example #11
Source File: SessionCreatedCondition.java    From planning-poker-plugin with MIT License 4 votes vote down vote up
@Override
public boolean shouldDisplay(Map<String, Object> context) {
    String key = ((Issue) context.get("issue")).getKey();
    return sessionService.get(key) != null;
}
 
Example #12
Source File: AbstractPokerService.java    From planning-poker-plugin with MIT License 4 votes vote down vote up
protected String getIssueStoreKey(Issue issue) {
    return KEY + ".sessions." + issue.getKey();
}
 
Example #13
Source File: Session.java    From planning-poker-plugin with MIT License 4 votes vote down vote up
public Issue getIssue() {
    return issue;
}
 
Example #14
Source File: Session.java    From planning-poker-plugin with MIT License 4 votes vote down vote up
public void setIssue(Issue issue) {
    this.issue = issue;
}