Search in sources :

Example 1 with IssueType

use of com.enonic.xp.issue.IssueType in project xp by enonic.

the class IssueDataSerializer method fromData.

public Issue.Builder fromData(final PropertySet issueProperties) {
    final IssueType issueType = issueProperties.getEnum(TYPE, IssueType.class);
    final Issue.Builder builder;
    if (IssueType.PUBLISH_REQUEST == issueType) {
        builder = PublishRequestIssue.create();
        publishRequestIssueSerializer.fromData(issueProperties, (PublishRequestIssue.Builder) builder);
    } else {
        builder = Issue.create();
    }
    builder.title(issueProperties.getString(TITLE));
    builder.description(issueProperties.getString(DESCRIPTION));
    builder.status(IssueStatus.valueOf(issueProperties.getString(STATUS)));
    builder.index(issueProperties.getLong(INDEX));
    extractUserInfo(issueProperties, builder);
    extractApprovers(issueProperties, builder);
    extractPublishRequest(issueProperties, builder);
    return builder;
}
Also used : PublishRequestIssue(com.enonic.xp.issue.PublishRequestIssue) PublishRequestIssue(com.enonic.xp.issue.PublishRequestIssue) Issue(com.enonic.xp.issue.Issue) IssueType(com.enonic.xp.issue.IssueType)

Example 2 with IssueType

use of com.enonic.xp.issue.IssueType in project xp by enonic.

the class IssueQueryNodeQueryTranslator method translate.

public static NodeQuery translate(final IssueQuery issueQuery) {
    final NodeQuery.Builder builder = NodeQuery.create();
    final ValueFilter issueCollectionFilter = ValueFilter.create().fieldName(NodeIndexPath.NODE_TYPE.getPath()).addValue(ValueFactory.newString(IssueConstants.ISSUE_NODE_COLLECTION.getName())).build();
    if (issueQuery.isCount()) {
        builder.searchMode(SearchMode.COUNT);
    }
    builder.from(issueQuery.getFrom()).size(issueQuery.getSize()).addQueryFilter(issueCollectionFilter);
    final PrincipalKey creator = issueQuery.getCreator();
    if (creator != null) {
        builder.addQueryFilter(ValueFilter.create().fieldName(CREATOR).addValues(creator.toString()).build());
    }
    final PrincipalKeys approvers = issueQuery.getApprovers();
    if (approvers != null && approvers.isNotEmpty()) {
        builder.addQueryFilter(ValueFilter.create().fieldName(APPROVERS).addValues(approvers.stream().map(PrincipalKey::toString).collect(toList())).build());
    }
    final ContentIds items = issueQuery.getItems();
    if (items != null && items.isNotEmpty()) {
        builder.addQueryFilter(ValueFilter.create().fieldName(PUBLISH_REQUEST_ITEM_ID).addValues(items.stream().map(ContentId::toString).collect(toList())).build());
    }
    final IssueStatus status = issueQuery.getStatus();
    if (status != null) {
        builder.addQueryFilter(ValueFilter.create().fieldName(STATUS).addValues(status.toString()).build());
    }
    final IssueType type = issueQuery.getType();
    if (type != null) {
        final Filter isOfType = ValueFilter.create().fieldName(TYPE).addValues(type.toString()).build();
        if (type == IssueType.STANDARD) {
            final Filter notExists = BooleanFilter.create().mustNot(ExistsFilter.create().fieldName(TYPE).build()).build();
            final Filter isStandard = BooleanFilter.create().should(isOfType).should(notExists).build();
            builder.addQueryFilter(isStandard);
        } else {
            builder.addQueryFilter(isOfType);
        }
    }
    builder.setOrderExpressions(IssueConstants.DEFAULT_CHILD_ORDER.getOrderExpressions());
    return builder.build();
}
Also used : PrincipalKeys(com.enonic.xp.security.PrincipalKeys) ExistsFilter(com.enonic.xp.query.filter.ExistsFilter) ValueFilter(com.enonic.xp.query.filter.ValueFilter) BooleanFilter(com.enonic.xp.query.filter.BooleanFilter) Filter(com.enonic.xp.query.filter.Filter) IssueType(com.enonic.xp.issue.IssueType) NodeQuery(com.enonic.xp.node.NodeQuery) ContentIds(com.enonic.xp.content.ContentIds) ValueFilter(com.enonic.xp.query.filter.ValueFilter) ContentId(com.enonic.xp.content.ContentId) PrincipalKey(com.enonic.xp.security.PrincipalKey) IssueStatus(com.enonic.xp.issue.IssueStatus)

Aggregations

IssueType (com.enonic.xp.issue.IssueType)2 ContentId (com.enonic.xp.content.ContentId)1 ContentIds (com.enonic.xp.content.ContentIds)1 Issue (com.enonic.xp.issue.Issue)1 IssueStatus (com.enonic.xp.issue.IssueStatus)1 PublishRequestIssue (com.enonic.xp.issue.PublishRequestIssue)1 NodeQuery (com.enonic.xp.node.NodeQuery)1 BooleanFilter (com.enonic.xp.query.filter.BooleanFilter)1 ExistsFilter (com.enonic.xp.query.filter.ExistsFilter)1 Filter (com.enonic.xp.query.filter.Filter)1 ValueFilter (com.enonic.xp.query.filter.ValueFilter)1 PrincipalKey (com.enonic.xp.security.PrincipalKey)1 PrincipalKeys (com.enonic.xp.security.PrincipalKeys)1