Search in sources :

Example 6 with EntityReference

use of com.khartec.waltz.model.EntityReference in project waltz by khartec.

the class SurveyInstanceIdSelectorFactory method apply.

@Override
public Select<Record1<Long>> apply(IdSelectionOptions options) {
    checkNotNull(options, "options cannot be null");
    EntityReference ref = options.entityReference();
    switch(ref.kind()) {
        case APP_GROUP:
        case APPLICATION:
        case CHANGE_INITIATIVE:
            return mkForNonHierarchicalEntity(ref, options.scope());
        case ORG_UNIT:
            return mkForOrgUnit(ref, options.scope());
        default:
            throw new IllegalArgumentException("Cannot create selector for entity kind: " + ref.kind());
    }
}
Also used : EntityReference(com.khartec.waltz.model.EntityReference)

Example 7 with EntityReference

use of com.khartec.waltz.model.EntityReference in project waltz by khartec.

the class ChangeLogEndpoint method register.

@Override
public void register() {
    getForList(mkPath(BASE_URL, "user", ":userId"), (request, response) -> service.findByUser(request.params("userId"), getLimit(request)));
    getForList(mkPath(BASE_URL, ":kind", ":id"), (request, response) -> {
        EntityReference ref = getEntityReference(request);
        if (ref.kind() == EntityKind.PERSON) {
            return service.findByPersonReference(ref, getLimit(request));
        } else {
            return service.findByParentReference(ref, getLimit(request));
        }
    });
}
Also used : EntityReference(com.khartec.waltz.model.EntityReference)

Example 8 with EntityReference

use of com.khartec.waltz.model.EntityReference in project waltz by khartec.

the class InvolvementEndpoint method updateEntityInvolvement.

private Boolean updateEntityInvolvement(Request request) throws java.io.IOException {
    EntityReference entityReference = getEntityReference(request);
    requireEditRoleForEntity(userRoleService, request, entityReference.kind());
    EntityInvolvementChangeCommand command = readBody(request, EntityInvolvementChangeCommand.class);
    String username = getUsername(request);
    switch(command.operation()) {
        case ADD:
            return service.addEntityInvolvement(username, entityReference, command);
        case REMOVE:
            return service.removeEntityInvolvement(username, entityReference, command);
        default:
            throw new UnsupportedOperationException("Command operation: " + command.operation() + " is not supported");
    }
}
Also used : EntityReference(com.khartec.waltz.model.EntityReference) EntityInvolvementChangeCommand(com.khartec.waltz.model.involvement.EntityInvolvementChangeCommand)

Example 9 with EntityReference

use of com.khartec.waltz.model.EntityReference in project waltz by khartec.

the class PerspectiveRatingEndpoint method updateForEntityAxis.

private int updateForEntityAxis(Request request, Response z) throws IOException {
    requireRole(userRoleService, request, Role.RATING_EDITOR);
    String username = getUsername(request);
    EntityReference ref = getEntityReference(request);
    long categoryX = getLong(request, "x");
    long categoryY = getLong(request, "y");
    PerspectiveRatingValue[] values = readBody(request, PerspectiveRatingValue[].class);
    return perspectiveRatingService.updatePerspectiveRatings(categoryX, categoryY, ref, username, fromArray(values));
}
Also used : PerspectiveRatingValue(com.khartec.waltz.model.perspective.PerspectiveRatingValue) EntityReference(com.khartec.waltz.model.EntityReference)

Example 10 with EntityReference

use of com.khartec.waltz.model.EntityReference in project waltz by khartec.

the class ChangeInitiativeIdSelectorFactory method mkForRef.

private Select<Record1<Long>> mkForRef(IdSelectionOptions options) {
    EntityReference ref = options.entityReference();
    Select<Record1<Long>> aToB = selectDistinct(ENTITY_RELATIONSHIP.ID_A).from(ENTITY_RELATIONSHIP).where(ENTITY_RELATIONSHIP.KIND_A.eq(EntityKind.CHANGE_INITIATIVE.name())).and(ENTITY_RELATIONSHIP.KIND_B.eq(ref.kind().name())).and(ENTITY_RELATIONSHIP.ID_B.eq(ref.id()));
    Select<Record1<Long>> bToA = selectDistinct(ENTITY_RELATIONSHIP.ID_B).from(ENTITY_RELATIONSHIP).where(ENTITY_RELATIONSHIP.KIND_B.eq(EntityKind.CHANGE_INITIATIVE.name())).and(ENTITY_RELATIONSHIP.KIND_A.eq(ref.kind().name())).and(ENTITY_RELATIONSHIP.ID_A.eq(ref.id()));
    return aToB.union(bToA);
}
Also used : EntityReference(com.khartec.waltz.model.EntityReference) Record1(org.jooq.Record1)

Aggregations

EntityReference (com.khartec.waltz.model.EntityReference)33 EntityKind (com.khartec.waltz.model.EntityKind)11 DSLContext (org.jooq.DSLContext)9 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)9 List (java.util.List)8 ListUtilities.newArrayList (com.khartec.waltz.common.ListUtilities.newArrayList)6 Collection (java.util.Collection)6 LogicalFlowDao (com.khartec.waltz.data.logical_flow.LogicalFlowDao)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 Checks.checkNotNull (com.khartec.waltz.common.Checks.checkNotNull)4 SetUtilities (com.khartec.waltz.common.SetUtilities)4 IdSelectionOptions (com.khartec.waltz.model.IdSelectionOptions)4 LogicalFlow (com.khartec.waltz.model.logical_flow.LogicalFlow)4 LOGICAL_FLOW (com.khartec.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW)4 DIConfiguration (com.khartec.waltz.service.DIConfiguration)4 EntityReference.mkRef (com.khartec.waltz.model.EntityReference.mkRef)3 ImmutableEntityReference (com.khartec.waltz.model.ImmutableEntityReference)3 Application (com.khartec.waltz.model.application.Application)3 OrganisationalUnit (com.khartec.waltz.model.orgunit.OrganisationalUnit)3 LogicalFlowService (com.khartec.waltz.service.logical_flow.LogicalFlowService)3