Search in sources :

Example 1 with GenericSelector

use of org.finos.waltz.data.GenericSelector in project waltz by khartec.

the class InvolvementService method findPeopleByGenericEntitySelector.

public List<Person> findPeopleByGenericEntitySelector(IdSelectionOptions selectionOptions) {
    checkNotNull(selectionOptions, "selectionOptions cannot be null");
    GenericSelector genericSelector = genericSelectorFactory.apply(selectionOptions);
    return involvementDao.findPeopleByGenericEntitySelector(genericSelector);
}
Also used : GenericSelector(org.finos.waltz.data.GenericSelector)

Example 2 with GenericSelector

use of org.finos.waltz.data.GenericSelector in project waltz by khartec.

the class FlowDiagramEntityService method findForEntitySelector.

public List<FlowDiagramEntity> findForEntitySelector(IdSelectionOptions options) {
    checkNotNull(options, "options cannot be null");
    GenericSelector selector = genericSelectorFactory.apply(options);
    return flowDiagramEntityDao.findForEntitySelector(selector.kind(), selector.selector());
}
Also used : GenericSelector(org.finos.waltz.data.GenericSelector)

Example 3 with GenericSelector

use of org.finos.waltz.data.GenericSelector in project waltz by khartec.

the class ComplexityService method getComplexitySummaryForSelector.

public ComplexitySummary getComplexitySummaryForSelector(Long complexityKindId, EntityKind targetKind, IdSelectionOptions options, int limit) {
    GenericSelector genericSelector = genericSelectorFactory.applyForKind(targetKind, options);
    Set<Complexity> topComplexities = complexityDao.findTopComplexityScoresForKindAndSelector(complexityKindId, genericSelector, limit);
    Tuple2<BigDecimal, BigDecimal> averageAndTotalScore = complexityDao.getAverageAndTotalScoreByKindAndSelector(complexityKindId, genericSelector);
    Tuple2<Integer, Integer> mappedAndMissingCountsForKindBySelector = complexityDao.getMappedAndMissingCountsForKindBySelector(complexityKindId, genericSelector);
    ComplexityKind complexityKind = complexityKindService.getById(complexityKindId);
    return ImmutableComplexitySummary.builder().complexityKind(complexityKind).topComplexityScores(topComplexities).average(averageAndTotalScore.v1.setScale(2, ROUND_HALF_UP)).total(averageAndTotalScore.v2).mappedCount(mappedAndMissingCountsForKindBySelector.v1).missingCount(mappedAndMissingCountsForKindBySelector.v2).build();
}
Also used : GenericSelector(org.finos.waltz.data.GenericSelector) BigDecimal(java.math.BigDecimal)

Example 4 with GenericSelector

use of org.finos.waltz.data.GenericSelector in project waltz by khartec.

the class SurveyRunService method generateSurveyInstanceRecipients.

public List<SurveyInstanceRecipient> generateSurveyInstanceRecipients(InstancesAndRecipientsCreateCommand command) {
    SurveyRun surveyRun = surveyRunDao.getById(command.surveyRunId());
    checkNotNull(surveyRun, "surveyRun " + command.surveyRunId() + " not found");
    SurveyTemplate surveyTemplate = surveyTemplateDao.getById(surveyRun.surveyTemplateId());
    checkNotNull(surveyTemplate, "surveyTemplate " + surveyRun.surveyTemplateId() + " not found");
    GenericSelector genericSelector = genericSelectorFactory.applyForKind(surveyTemplate.targetEntityKind(), surveyRun.selectionOptions());
    Map<EntityReference, List<Person>> entityRefToPeople = involvementDao.findPeopleByEntitySelectorAndInvolvement(surveyTemplate.targetEntityKind(), genericSelector.selector(), surveyRun.involvementKindIds());
    return entityRefToPeople.entrySet().stream().flatMap(e -> e.getValue().stream().map(p -> ImmutableSurveyInstanceRecipient.builder().surveyInstance(ImmutableSurveyInstance.builder().surveyEntity(e.getKey()).surveyRunId(surveyRun.id().get()).status(SurveyInstanceStatus.NOT_STARTED).dueDate(command.dueDate()).approvalDueDate(command.approvalDueDate()).owningRole(command.owningRole()).build()).person(p).build())).distinct().collect(toList());
}
Also used : org.finos.waltz.data.survey(org.finos.waltz.data.survey) java.util(java.util) org.finos.waltz.model(org.finos.waltz.model) InvolvementDao(org.finos.waltz.data.involvement.InvolvementDao) GenericSelector(org.finos.waltz.data.GenericSelector) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) Autowired(org.springframework.beans.factory.annotation.Autowired) ImmutableChangeLog(org.finos.waltz.model.changelog.ImmutableChangeLog) Person(org.finos.waltz.model.person.Person) Checks.checkTrue(org.finos.waltz.common.Checks.checkTrue) GenericSelectorFactory(org.finos.waltz.data.GenericSelectorFactory) Record1(org.jooq.Record1) Service(org.springframework.stereotype.Service) MapUtilities.groupBy(org.finos.waltz.common.MapUtilities.groupBy) Select(org.jooq.Select) ChangeLogService(org.finos.waltz.service.changelog.ChangeLogService) org.finos.waltz.model.survey(org.finos.waltz.model.survey) PersonDao(org.finos.waltz.data.person.PersonDao) MapUtilities.indexBy(org.finos.waltz.common.MapUtilities.indexBy) ListUtilities.map(org.finos.waltz.common.ListUtilities.map) Collectors.toList(java.util.stream.Collectors.toList) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) ListUtilities(org.finos.waltz.common.ListUtilities) LocalDate(java.time.LocalDate) SetUtilities(org.finos.waltz.common.SetUtilities) SetUtilities.fromCollection(org.finos.waltz.common.SetUtilities.fromCollection) GenericSelector(org.finos.waltz.data.GenericSelector) Collectors.toList(java.util.stream.Collectors.toList)

Example 5 with GenericSelector

use of org.finos.waltz.data.GenericSelector in project waltz by khartec.

the class EntityCostExtractor method registerCostsForSelector.

private void registerCostsForSelector(String costsForSelectorPath) {
    post(costsForSelectorPath, (request, response) -> {
        IdSelectionOptions idSelectionOptions = WebUtilities.readIdSelectionOptionsFromBody(request);
        EntityKind targetKind = WebUtilities.getKind(request);
        GenericSelector genericSelector = genericSelectorFactory.applyForKind(targetKind, idSelectionOptions);
        SelectJoinStep<Record1<Integer>> latestYear = DSL.select(DSL.max(COST.YEAR)).from(COST);
        SelectSeekStep2<Record, String, Long> qry = dsl.select(COST.ENTITY_ID.as("Entity ID"), COST.ENTITY_KIND.as("Entity Kind")).select(ENTITY_NAME_FIELD.as("Name")).select(COST_KIND.NAME.as("Kind"), COST_KIND.DESCRIPTION.as("Kind Description")).select(COST.YEAR.as("Year"), COST.AMOUNT.as("Amount"), COST.PROVENANCE.as("Provenance")).from(COST).innerJoin(COST_KIND).on(COST.COST_KIND_ID.eq(COST_KIND.ID)).where(COST.ENTITY_ID.in(genericSelector.selector()).and(COST.ENTITY_KIND.eq(genericSelector.kind().name()))).and(COST.YEAR.eq(latestYear)).orderBy(ENTITY_NAME_FIELD.as("Name"), COST.COST_KIND_ID);
        return writeExtract(mkFilename(idSelectionOptions.entityReference()), qry, request, response);
    });
}
Also used : GenericSelector(org.finos.waltz.data.GenericSelector) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) EntityKind(org.finos.waltz.model.EntityKind)

Aggregations

GenericSelector (org.finos.waltz.data.GenericSelector)13 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)4 BigDecimal (java.math.BigDecimal)2 LocalDate (java.time.LocalDate)2 java.util (java.util)2 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)2 Collectors.toList (java.util.stream.Collectors.toList)2 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)2 Checks.checkTrue (org.finos.waltz.common.Checks.checkTrue)2 ListUtilities (org.finos.waltz.common.ListUtilities)2 ListUtilities.map (org.finos.waltz.common.ListUtilities.map)2 MapUtilities.groupBy (org.finos.waltz.common.MapUtilities.groupBy)2 MapUtilities.indexBy (org.finos.waltz.common.MapUtilities.indexBy)2 SetUtilities (org.finos.waltz.common.SetUtilities)2 SetUtilities.fromCollection (org.finos.waltz.common.SetUtilities.fromCollection)2 GenericSelectorFactory (org.finos.waltz.data.GenericSelectorFactory)2 InvolvementDao (org.finos.waltz.data.involvement.InvolvementDao)2 PersonDao (org.finos.waltz.data.person.PersonDao)2 org.finos.waltz.data.survey (org.finos.waltz.data.survey)2 org.finos.waltz.model (org.finos.waltz.model)2