Search in sources :

Example 11 with Relation

use of se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.Relation in project webcert by sklintyg.

the class IntygRelationHelperImpl method applyRelation.

/*
     * In this context, all (draft) statuses are SIGNED.
     */
private void applyRelation(String intygId, Relations certificateRelations, Relation r) {
    if (r.getTillIntygsId().getExtension().equals(intygId)) {
        Relations.FrontendRelations latest = certificateRelations.getLatestChildRelations();
        WebcertCertificateRelation wcr = createWebcertCertificateRelation(r, true);
        switch(wcr.getRelationKod()) {
            case ERSATT:
                if (firstSkapadLaterDateThanSecond(wcr, latest.getReplacedByIntyg())) {
                    latest.setReplacedByIntyg(wcr);
                } else if (firstSkapadLaterDateThanSecond(wcr, latest.getReplacedByUtkast())) {
                    latest.setReplacedByUtkast(wcr);
                }
                break;
            case KOMPLT:
                if (firstSkapadLaterDateThanSecond(wcr, latest.getComplementedByIntyg())) {
                    latest.setComplementedByIntyg(wcr);
                } else if (firstSkapadLaterDateThanSecond(wcr, latest.getComplementedByUtkast())) {
                    latest.setComplementedByUtkast(wcr);
                }
                break;
            case FRLANG:
                break;
        }
    } else if (r.getFranIntygsId().getExtension().equals(intygId)) {
        certificateRelations.setParent(createWebcertCertificateRelation(r, false));
    }
}
Also used : WebcertCertificateRelation(se.inera.intyg.webcert.common.model.WebcertCertificateRelation) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) IntygRelations(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.IntygRelations)

Example 12 with Relation

use of se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.Relation in project kie-wb-common by kiegroup.

the class RelationPropertyConverter method wbFromDMN.

public static Relation wbFromDMN(final org.kie.dmn.model.v1_1.Relation dmn) {
    Id id = new Id(dmn.getId());
    Description description = new Description(dmn.getDescription());
    QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
    List<org.kie.dmn.model.v1_1.InformationItem> column = dmn.getColumn();
    List<org.kie.dmn.model.v1_1.List> row = dmn.getRow();
    List<InformationItem> convertedColumn = column.stream().map(InformationItemPropertyConverter::wbFromDMN).collect(Collectors.toList());
    List<org.kie.workbench.common.dmn.api.definition.v1_1.List> convertedRow = row.stream().map(ListPropertyConverter::wbFromDMN).collect(Collectors.toList());
    Relation result = new Relation(id, description, typeRef, convertedColumn, convertedRow);
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Relation(org.kie.workbench.common.dmn.api.definition.v1_1.Relation) List(java.util.List) Id(org.kie.workbench.common.dmn.api.property.dmn.Id)

Example 13 with Relation

use of se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.Relation in project kie-wb-common by kiegroup.

the class MoveColumnsCommand method newGraphCommand.

@Override
protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) {
    return new AbstractGraphCommand() {

        @Override
        protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) {
            return isColumnInValidSection() ? GraphCommandResultBuilder.SUCCESS : GraphCommandResultBuilder.FAILED;
        }

        private boolean isColumnInValidSection() {
            final RelationSection section = RelationUIModelMapperHelper.getSection(relation, index);
            return section == RelationSection.INFORMATION_ITEM;
        }

        @Override
        public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) {
            return moveInformationItems(index);
        }

        @Override
        public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) {
            return moveInformationItems(oldIndex);
        }

        private CommandResult<RuleViolation> moveInformationItems(final int index) {
            final RelationSection section = RelationUIModelMapperHelper.getSection(relation, index);
            if (section == RelationSection.INFORMATION_ITEM) {
                final int oldIndex = uiModel.getColumns().indexOf(columns.get(0));
                final int relativeIndex = RelationUIModelMapperHelper.getInformationItemIndex(relation, index);
                final int relativeOldIndex = RelationUIModelMapperHelper.getInformationItemIndex(relation, oldIndex);
                final java.util.List<Integer> informationItemIndexesToMove = columns.stream().map(c -> uiModel.getColumns().indexOf(c)).map(i -> RelationUIModelMapperHelper.getInformationItemIndex(relation, i)).collect(Collectors.toList());
                moveInformationItems(relativeIndex, relativeOldIndex, relation.getColumn(), informationItemIndexesToMove);
                updateRowsData(relativeIndex, relativeOldIndex, relation.getRow(), informationItemIndexesToMove);
                return GraphCommandResultBuilder.SUCCESS;
            } else {
                return GraphCommandResultBuilder.FAILED;
            }
        }

        private <T> void moveInformationItems(final int relativeIndex, final int relativeOldIndex, final java.util.List<T> informationItems, final java.util.List<Integer> informationItemIndexesToMove) {
            final java.util.List<T> informationItemsToMove = informationItemIndexesToMove.stream().map(informationItems::get).collect(Collectors.toList());
            informationItems.removeAll(informationItemsToMove);
            if (relativeIndex < relativeOldIndex) {
                informationItems.addAll(relativeIndex, informationItemsToMove);
            } else if (relativeIndex > relativeOldIndex) {
                informationItems.addAll(relativeIndex - informationItemsToMove.size() + 1, informationItemsToMove);
            }
        }

        private void updateRowsData(final int relativeIndex, final int relativeOldIndex, final java.util.List<List> rows, final java.util.List<Integer> informationItemIndexesToMove) {
            rows.forEach(row -> moveInformationItems(relativeIndex, relativeOldIndex, row.getExpression(), informationItemIndexesToMove));
        }
    };
}
Also used : RelationSection(org.kie.workbench.common.dmn.client.editors.expressions.types.relation.RelationUIModelMapperHelper.RelationSection) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) RelationUIModelMapperHelper(org.kie.workbench.common.dmn.client.editors.expressions.types.relation.RelationUIModelMapperHelper) CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) VetoExecutionCommand(org.kie.workbench.common.dmn.client.commands.VetoExecutionCommand) CanvasCommandResultBuilder(org.kie.workbench.common.stunner.core.client.command.CanvasCommandResultBuilder) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) AbstractCanvasCommand(org.kie.workbench.common.stunner.core.client.canvas.command.AbstractCanvasCommand) Collectors(java.util.stream.Collectors) AbstractCanvasGraphCommand(org.kie.workbench.common.stunner.core.client.canvas.command.AbstractCanvasGraphCommand) ArrayList(java.util.ArrayList) CommandUtils(org.kie.workbench.common.dmn.client.commands.util.CommandUtils) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) AbstractGraphCommand(org.kie.workbench.common.stunner.core.graph.command.impl.AbstractGraphCommand) Relation(org.kie.workbench.common.dmn.api.definition.v1_1.Relation) Command(org.kie.workbench.common.stunner.core.command.Command) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) GraphCommandResultBuilder(org.kie.workbench.common.stunner.core.graph.command.GraphCommandResultBuilder) VetoUndoCommand(org.kie.workbench.common.dmn.client.commands.VetoUndoCommand) CommandResult(org.kie.workbench.common.stunner.core.command.CommandResult) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) AbstractGraphCommand(org.kie.workbench.common.stunner.core.graph.command.impl.AbstractGraphCommand) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) ArrayList(java.util.ArrayList) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) RelationSection(org.kie.workbench.common.dmn.client.editors.expressions.types.relation.RelationUIModelMapperHelper.RelationSection)

Example 14 with Relation

use of se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.Relation in project kie-wb-common by kiegroup.

the class RelationEditorDefinitionTest method testEditor.

@Test
public void testEditor() {
    final Optional<Relation> expression = definition.getModelClass();
    final Optional<BaseExpressionGrid> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, expression, hasName, 0);
    assertThat(oEditor).isPresent();
    final GridWidget editor = oEditor.get();
    assertThat(editor).isInstanceOf(RelationGrid.class);
}
Also used : Relation(org.kie.workbench.common.dmn.api.definition.v1_1.Relation) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) Test(org.junit.Test)

Example 15 with Relation

use of se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.Relation in project kie-wb-common by kiegroup.

the class DeleteRelationColumnCommandTest method setup.

@Before
public void setup() {
    this.relation = new Relation();
    this.informationItem = new InformationItem();
    this.relation.getColumn().add(informationItem);
    this.uiModel = new BaseGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiModelColumn);
    doReturn(ruleManager).when(handler).getRuleManager();
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiModelColumn).getIndex();
    this.uiModelMapper = new RelationUIModelMapper(() -> uiModel, () -> Optional.of(relation), listSelector);
}
Also used : RelationUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.relation.RelationUIModelMapper) Relation(org.kie.workbench.common.dmn.api.definition.v1_1.Relation) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Aggregations

Relation (org.kie.workbench.common.dmn.api.definition.v1_1.Relation)12 Before (org.junit.Before)7 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)6 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)4 RelationUIModelMapper (org.kie.workbench.common.dmn.client.editors.expressions.types.relation.RelationUIModelMapper)4 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)4 WebcertCertificateRelation (se.inera.intyg.webcert.common.model.WebcertCertificateRelation)4 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)3 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)3 IntygRelations (se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.IntygRelations)3 Relation (se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.Relation)3 Relations (se.inera.intyg.webcert.web.web.controller.api.dto.Relations)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 InformationItem (org.kie.dmn.model.v1_1.InformationItem)2 Relation (org.kie.dmn.model.v1_1.Relation)2 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)2 ListRelationsForCertificateResponseType (se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.ListRelationsForCertificateResponseType)2 ListIntygEntry (se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)2