Search in sources :

Example 6 with AssessmentDefinition

use of org.finos.waltz.model.assessment_definition.AssessmentDefinition in project waltz by khartec.

the class AssessmentRatingExtractor method register.

@Override
public void register() {
    post(WebUtilities.mkPath("data-extract", "assessment-rating", "by-definition", ":id"), (request, response) -> {
        long definitionId = WebUtilities.getId(request);
        AssessmentDefinition definition = assessmentDefinitionDao.getById(definitionId);
        SelectConditionStep<?> qry = prepareExtractQuery(definitionId);
        String fileName = String.format("assessment-ratings-for-%s", definition.name().toLowerCase());
        LOG.debug("extracted assessment ratings for definition {}", definition.name());
        return writeExtract(fileName, qry, request, response);
    });
}
Also used : AssessmentDefinition(org.finos.waltz.model.assessment_definition.AssessmentDefinition)

Example 7 with AssessmentDefinition

use of org.finos.waltz.model.assessment_definition.AssessmentDefinition in project waltz by khartec.

the class AssessmentDefinitionEndpoint method saveRoute.

private long saveRoute(Request request, Response response) throws IOException {
    ensureUserHasEditRights(request);
    AssessmentDefinition def = ImmutableAssessmentDefinition.copyOf(WebUtilities.readBody(request, AssessmentDefinition.class)).withLastUpdatedAt(DateTimeUtilities.nowUtc()).withLastUpdatedBy(WebUtilities.getUsername(request));
    return assessmentDefinitionService.save(def);
}
Also used : AssessmentDefinition(org.finos.waltz.model.assessment_definition.AssessmentDefinition) ImmutableAssessmentDefinition(org.finos.waltz.model.assessment_definition.ImmutableAssessmentDefinition)

Example 8 with AssessmentDefinition

use of org.finos.waltz.model.assessment_definition.AssessmentDefinition in project waltz by khartec.

the class AssessmentRatingEndpoint method verifyCanWrite.

private void verifyCanWrite(Request request, long defId) {
    AssessmentDefinition def = assessmentDefinitionService.getById(defId);
    def.permittedRole().ifPresent(r -> requireRole(userRoleService, request, r));
    if (def.isReadOnly()) {
        throw new NotAuthorizedException("Assessment is read-only");
    }
}
Also used : AssessmentDefinition(org.finos.waltz.model.assessment_definition.AssessmentDefinition) NotAuthorizedException(org.finos.waltz.web.NotAuthorizedException)

Aggregations

AssessmentDefinition (org.finos.waltz.model.assessment_definition.AssessmentDefinition)8 Autowired (org.springframework.beans.factory.annotation.Autowired)3 String.format (java.lang.String.format)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)2 MapUtilities (org.finos.waltz.common.MapUtilities)2 StringUtilities (org.finos.waltz.common.StringUtilities)2 GenericSelector (org.finos.waltz.data.GenericSelector)2 GenericSelectorFactory (org.finos.waltz.data.GenericSelectorFactory)2 AssessmentDefinitionDao (org.finos.waltz.data.assessment_definition.AssessmentDefinitionDao)2 AssessmentRatingDao (org.finos.waltz.data.assessment_rating.AssessmentRatingDao)2 RatingSchemeDAO (org.finos.waltz.data.rating_scheme.RatingSchemeDAO)2 org.finos.waltz.model (org.finos.waltz.model)2 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)2 ImmutableAssessmentDefinition (org.finos.waltz.model.assessment_definition.ImmutableAssessmentDefinition)2 org.finos.waltz.model.assessment_rating (org.finos.waltz.model.assessment_rating)2 ChangeLog (org.finos.waltz.model.changelog.ChangeLog)2 ImmutableChangeLog (org.finos.waltz.model.changelog.ImmutableChangeLog)2 RatingSchemeItem (org.finos.waltz.model.rating.RatingSchemeItem)2