Search in sources :

Example 61 with EntityReference

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);
    });
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Example 62 with EntityReference

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);
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) Collection(java.util.Collection) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Example 63 with EntityReference

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));
}
Also used : EntityReference(org.finos.waltz.model.EntityReference)

Example 64 with EntityReference

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);
    });
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) Date(java.util.Date)

Example 65 with EntityReference

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);
}
Also used : Bookmark(org.finos.waltz.model.bookmark.Bookmark) EntityReference(org.finos.waltz.model.EntityReference)

Aggregations

EntityReference (org.finos.waltz.model.EntityReference)114 BaseInMemoryIntegrationTest (org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest)55 Test (org.junit.jupiter.api.Test)55 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)40 EntityKind (org.finos.waltz.model.EntityKind)23 List (java.util.List)21 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)19 Autowired (org.springframework.beans.factory.annotation.Autowired)17 DataTypeDecorator (org.finos.waltz.model.datatype.DataTypeDecorator)16 Set (java.util.Set)14 Collection (java.util.Collection)13 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)13 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)10 IdSelectionOptions.mkOpts (org.finos.waltz.model.IdSelectionOptions.mkOpts)9 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)8 ListUtilities.newArrayList (org.finos.waltz.common.ListUtilities.newArrayList)8 Bookmark (org.finos.waltz.model.bookmark.Bookmark)8 Collections.emptyList (java.util.Collections.emptyList)7 Collectors (java.util.stream.Collectors)7 CollectionUtilities.first (org.finos.waltz.common.CollectionUtilities.first)7