use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class LicencesExtractor method register.
@Override
public void register() {
String path = WebUtilities.mkPath("data-extract", "licences", ":kind", ":id");
get(path, (request, response) -> {
EntityReference entityRef = WebUtilities.getEntityReference(request);
IdSelectionOptions selectionOptions = mkOpts(entityRef);
Select<Record1<Long>> appIdSelector = applicationIdSelectorFactory.apply(selectionOptions);
SelectConditionStep<Record8<Long, String, String, String, String, Timestamp, String, String>> qry = dsl.selectDistinct(LICENCE.ID.as("Licence Id"), LICENCE.NAME.as("Licence Name"), LICENCE.DESCRIPTION.as("Description"), LICENCE.EXTERNAL_ID.as("External Id"), LICENCE.APPROVAL_STATUS.as("Approval Status"), LICENCE.LAST_UPDATED_AT.as("Last Updated At"), LICENCE.LAST_UPDATED_BY.as("Last Updated By"), LICENCE.PROVENANCE.as("Provenance")).from(SOFTWARE_USAGE).innerJoin(SOFTWARE_VERSION_LICENCE).on(SOFTWARE_VERSION_LICENCE.SOFTWARE_VERSION_ID.eq(SOFTWARE_USAGE.SOFTWARE_VERSION_ID)).innerJoin(LICENCE).on(LICENCE.ID.eq(SOFTWARE_VERSION_LICENCE.LICENCE_ID)).where(dsl.renderInlined(SOFTWARE_USAGE.APPLICATION_ID.in(appIdSelector)));
String filename = format("licences-%s/%s", entityRef.kind(), entityRef.id());
return writeExtract(filename, qry, request, response);
});
}
use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class FlowClassificationRuleEndpoint method calculateConsumersForDataTypeIdSelectorRoute.
private List<Entry<EntityReference, Collection<EntityReference>>> calculateConsumersForDataTypeIdSelectorRoute(Request request, Response response) throws IOException {
IdSelectionOptions options = WebUtilities.readIdSelectionOptionsFromBody(request);
Map<EntityReference, Collection<EntityReference>> result = flowClassificationRuleService.calculateConsumersForDataTypeIdSelector(options);
return WebUtilities.simplifyMapToList(result);
}
use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class MeasurableRatingEndpoint method removeCategoryRoute.
private Collection<MeasurableRating> removeCategoryRoute(Request request, Response z) {
EntityReference ref = getEntityReference(request);
long categoryId = getLong(request, "categoryId");
requireRole(userRoleService, request, measurableRatingService.getRequiredRatingEditRole(mkRef(EntityKind.MEASURABLE_CATEGORY, categoryId)));
return measurableRatingService.removeForCategory(ref, categoryId, getUsername(request));
}
use of org.finos.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)));
postForList(mkPath(BASE_URL, "summaries", ":kind"), (request, response) -> service.findCountByDateForParentKindBySelector(getKind(request), readIdSelectionOptionsFromBody(request), getLimit(request)));
getForList(mkPath(BASE_URL, ":kind", ":id"), (request, response) -> {
EntityReference ref = getEntityReference(request);
Optional<Date> dateParam = getDateParam(request);
Optional<Integer> limitParam = getLimit(request);
if (ref.kind() == EntityKind.PERSON) {
return service.findByPersonReference(ref, dateParam, limitParam);
} else {
return service.findByParentReference(ref, dateParam, limitParam);
}
});
getForList(mkPath(BASE_URL, ":kind", ":id", "unattested"), (request, response) -> {
EntityReference ref = getEntityReference(request);
return service.findUnattestedChanges(ref);
});
}
use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class BookmarksEndpoint method register.
@Override
public void register() {
get(mkPath(BASE_URL, ":kind", ":id"), (request, response) -> {
response.type(TYPE_JSON);
EntityReference ref = getEntityReference(request);
return bookmarkService.findByReference(ref);
}, transformer);
post(mkPath(BASE_URL), (request, response) -> {
requireRole(userRoleService, request, SystemRole.BOOKMARK_EDITOR);
response.type(TYPE_JSON);
Bookmark bookmark = readBody(request, Bookmark.class);
LOG.info("Saving bookmark: " + bookmark);
boolean isUpdate = bookmark.id().isPresent();
return isUpdate ? bookmarkService.update(bookmark, getUsername(request)) : bookmarkService.create(bookmark, getUsername(request));
}, transformer);
delete(mkPath(BASE_URL, ":id"), (request, response) -> {
requireRole(userRoleService, request, SystemRole.BOOKMARK_EDITOR);
response.type(TYPE_JSON);
long bookmarkId = getId(request);
Bookmark bookmark = bookmarkService.getById(bookmarkId);
if (bookmark == null) {
LOG.warn("Attempt made to delete non-existent bookmark: " + bookmarkId);
return false;
}
LOG.info("Deleting bookmark: " + bookmark);
return bookmarkService.deleteById(bookmark, getUsername(request));
}, transformer);
}
Aggregations