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());
}
}
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));
}
});
}
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");
}
}
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));
}
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);
}
Aggregations