use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class SurveyQuestionResponseDao method mkRecord.
private SurveyQuestionResponseRecord mkRecord(SurveyInstanceQuestionResponse response) {
SurveyQuestionResponse questionResponse = response.questionResponse();
Optional<EntityReference> entityResponse = questionResponse.entityResponse();
SurveyQuestionResponseRecord record = dsl.newRecord(SURVEY_QUESTION_RESPONSE);
record.setSurveyInstanceId(response.surveyInstanceId());
record.setQuestionId(questionResponse.questionId());
record.setPersonId(response.personId());
record.setLastUpdatedAt(Timestamp.valueOf(response.lastUpdatedAt()));
record.setComment(questionResponse.comment().map(c -> ifEmpty(c, null)).orElse(null));
record.setStringResponse(questionResponse.stringResponse().map(s -> ifEmpty(s, null)).orElse(null));
record.setNumberResponse(questionResponse.numberResponse().map(BigDecimal::valueOf).orElse(null));
record.setBooleanResponse(questionResponse.booleanResponse().orElse(null));
record.setDateResponse(questionResponse.dateResponse().map(DateTimeUtilities::toSqlDate).orElse(null));
record.setEntityResponseKind(entityResponse.map(er -> er.kind().name()).orElse(null));
record.setEntityResponseId(entityResponse.map(EntityReference::id).orElse(null));
record.setListResponseConcat(questionResponse.listResponse().filter(l -> !l.isEmpty()).map(l -> join(l, "; ")).orElse(null));
return record;
}
use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class AttestationServiceTest method cannotAttestIfNotAssociated.
@Test
public void cannotAttestIfNotAssociated() {
String user = mkUserId("cannotAttestIfNotAssociated");
EntityReference appRef = mkNewAppRef();
AttestEntityCommand cmd = ImmutableAttestEntityCommand.builder().attestedEntityKind(EntityKind.LOGICAL_DATA_FLOW).entityReference(appRef).build();
assertThrows(UpdateFailedException.class, () -> aiSvc.attestForEntity(user, cmd), "Should not be able to attest as user not associated to app");
}
use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class AttestationServiceTest method cannotAttestIfNoFlows.
@Test
public void cannotAttestIfNoFlows() {
long invId = involvementHelper.mkInvolvementKind(mkName("cannotAttestIfNoFlows"));
String user = mkUserId("cannotAttestIfNotAssociated");
EntityReference appRef = mkNewAppRef();
involvementHelper.createInvolvement(personHelper.createPerson(user), invId, appRef);
AttestEntityCommand cmd = ImmutableAttestEntityCommand.builder().attestedEntityKind(EntityKind.LOGICAL_DATA_FLOW).entityReference(appRef).build();
assertThrows(Exception.class, () -> aiSvc.attestForEntity(user, cmd), "Should not be able to attest as no flows");
}
use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class ContextPopulatorTest method fooTest.
@Test
public void fooTest() {
EntityReference a1 = appHelper.createNewApp(mkName("a1"), ouIds.a);
EntityReference a2 = appHelper.createNewApp(mkName("a2"), ouIds.a);
EntityReference a3 = appHelper.createNewApp(mkName("a3"), ouIds.a);
RatingSchemeRecord scheme = dsl.newRecord(rs);
scheme.setName(mkName("scheme"));
scheme.setDescription("desc");
scheme.store();
RatingSchemeItemRecord ratingItem1 = mkRatingItem(scheme, "ratingItem1", "X");
RatingSchemeItemRecord ratingItem2 = mkRatingItem(scheme, "ratingItem2", "Y");
AssessmentDefinitionRecord def1 = mkAssessmentDef("def1", scheme);
AssessmentDefinitionRecord def2 = mkAssessmentDef("anotherDef", scheme);
mkRating(a1, def1, ratingItem1);
mkRating(a2, def1, ratingItem2);
mkRating(a1, def2, ratingItem2);
Set<ContextVariableDeclaration> declarations = SetUtilities.asSet(ImmutableContextVariableDeclaration.builder().name("def1Var").ref(mkVarRef(EntityKind.ASSESSMENT_DEFINITION, def1.getExternalId())).build(), ImmutableContextVariableDeclaration.builder().name("def1VarDupe").ref(mkVarRef(EntityKind.ASSESSMENT_DEFINITION, def1.getExternalId())).build(), ImmutableContextVariableDeclaration.builder().name("def2Var").ref(mkVarRef(EntityKind.ASSESSMENT_DEFINITION, def2.getExternalId())).build());
Set<ContextVariable<? extends ContextValue>> vars = populator.populateContext(declarations, selector);
assertVar(vars, a1, "def1Var", mkAssessmentCodeCheck("X"), "A1");
assertVar(vars, a1, "def2Var", mkAssessmentCodeCheck("Y"), "A1");
assertVar(vars, a1, "def1VarDupe", mkAssessmentCodeCheck("X"), "A1");
assertVar(vars, a2, "def1Var", mkAssessmentCodeCheck("Y"), "A2");
assertVar(vars, a2, "def1VarDupe", mkAssessmentCodeCheck("Y"), "A2");
}
use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class PermissionGroupService method findPermissions.
public List<Permission> findPermissions(EntityReference parentEntityRef, String username) {
Person person = personService.getPersonByUserId(username);
if (isNull(person)) {
return Collections.emptyList();
}
List<Involvement> involvements = involvementService.findByEmployeeId(person.employeeId()).stream().filter(involvement -> involvement.entityReference().equals(parentEntityRef)).collect(Collectors.toList());
if (involvements.isEmpty()) {
return Collections.emptyList();
}
return permissionGroupDao.getDefaultPermissions();
}
Aggregations