Search in sources :

Example 1 with ArchitectureRuleConfig

use of org.archcnl.domain.input.model.presets.ArchitectureRuleConfig in project ArchCNL by Mari-Wie.

the class ArchitectureRuleSelection method addRulesToUi.

private void addRulesToUi(List<ArchitectureRuleConfig> rulesFromConfig) {
    // TODO Auto-generated method stub
    architectureRulesSelect = new CheckboxGroup<String>();
    architectureRulesSelect.addThemeVariants(CheckboxGroupVariant.LUMO_VERTICAL);
    Set<String> knownRules = new HashSet<String>();
    for (ArchitectureRuleConfig architectureRuleString : rulesFromConfig) {
        knownRules.add(architectureRuleString.getRule());
    }
    architectureRulesSelect.setItems(knownRules);
    VerticalLayout layout = new VerticalLayout();
    layout.add(new Text("Please choose the architecture rules you want to apply."));
    architectureRulesSelect.select(knownRules);
    layout.setWidthFull();
    layout.add(architectureRulesSelect);
    add(layout);
}
Also used : ArchitectureRuleConfig(org.archcnl.domain.input.model.presets.ArchitectureRuleConfig) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) Text(com.vaadin.flow.component.Text) HashSet(java.util.HashSet)

Example 2 with ArchitectureRuleConfig

use of org.archcnl.domain.input.model.presets.ArchitectureRuleConfig in project ArchCNL by Mari-Wie.

the class PresetsDialogPresenter method handleEvent.

private void handleEvent(ArchitectureRulesSelectedEvent event) {
    ArchitectureRuleSelection ruleSelection = (ArchitectureRuleSelection) tabsToComponent.get(ruleSelectionTab);
    Set<String> selectedRules = ruleSelection.getSelectedRules();
    // deactivate the variable architecture informations that are not selected
    for (ArchitectureRuleConfig ruleConfig : architectureConfig.getRules()) {
        String ruleToCheck = ruleConfig.getRule();
        if (!selectedRules.contains(ruleToCheck)) {
            // if not selected set active to false
            ruleConfig.setActive(false);
            List<Integer> idsToDeactiate = ruleConfig.getRequiredArchitectureInformationIds();
            List<ArchitectureInformation> variableArchitectureInfomation = architectureConfig.getVariableParts();
            // loop all Architecture Information
            for (ArchitectureInformation architectureInformation : variableArchitectureInfomation) {
                // check if the id is within the ids that should be deactivated
                if (idsToDeactiate.contains(architectureInformation.getId())) {
                    architectureInformation.setActive(false);
                }
            }
        }
    }
    ArchitecturalStyleForm form = new ArchitecturalStyleForm(architectureConfig);
    tabsToComponent.put(architectureInformationTab, form);
    enableTab(architectureInformationTab);
    tabs.setSelectedTab(architectureInformationTab);
    view.updateTabsToComponent(tabsToComponent);
    view.updateFooter(TabOptions.ARCHITECTURE_INFORMATION);
    view.showTab(tabs.getSelectedTab());
}
Also used : ArchitectureRuleConfig(org.archcnl.domain.input.model.presets.ArchitectureRuleConfig) ArchitectureInformation(org.archcnl.domain.input.model.presets.ArchitectureInformation)

Example 3 with ArchitectureRuleConfig

use of org.archcnl.domain.input.model.presets.ArchitectureRuleConfig in project ArchCNL by Mari-Wie.

the class PresetsDialogPresenter method createRulesAndMappingsForMicroserviceArchitecture.

private void createRulesAndMappingsForMicroserviceArchitecture(ArchitectureRuleManager ruleManager, ConceptManager conceptManager, RelationManager relationManager) {
    MicroserviceArchitectureBuilder microserviceArchitectureBuilder = new MicroserviceArchitectureBuilder();
    ArchitecturalStyleForm form = (ArchitecturalStyleForm) tabsToComponent.get(architectureInformationTab);
    Map<String, Binder<ArchitectureInformation>> architectureInfoBinders = form.getUngroupedArchitectureInformationBinders();
    Map<Integer, Set<TwoColumnGridEntry>> architectureInformationGroupsAndEntries = form.getArchitectureInformationGroupsAndEntries();
    // map ungrouped architecture information
    mapUiInputToArchitectureInformation(microserviceArchitectureBuilder, architectureInfoBinders);
    // map grouped architecture information
    mapGroupedUIInputsToArchitectureInformation(microserviceArchitectureBuilder, architectureInformationGroupsAndEntries);
    // create the rules
    MicroserviceArchitecture microserviceArchitecture = microserviceArchitectureBuilder.build();
    // only rules that are selected
    Set<String> rulesToCreate = new HashSet<String>();
    for (ArchitectureRuleConfig ruleConfig : architectureConfig.getRules()) {
        if (ruleConfig.isActive()) {
            rulesToCreate.add(ruleConfig.getRule());
        }
    }
    microserviceArchitecture.setArchitectureRules(rulesToCreate);
    microserviceArchitecture.createRulesAndMappings(ruleManager, conceptManager, relationManager);
    // this updates Concepts/Rules/Relations in the MainView
    fireEvent(new UpdateRulesConceptsAndRelationsRequestedEvent(this, false));
}
Also used : ArchitectureRuleConfig(org.archcnl.domain.input.model.presets.ArchitectureRuleConfig) HashSet(java.util.HashSet) Set(java.util.Set) MicroserviceArchitectureBuilder(org.archcnl.domain.input.model.presets.microservicearchitecture.MicroserviceArchitectureBuilder) Binder(com.vaadin.flow.data.binder.Binder) MicroserviceArchitecture(org.archcnl.domain.input.model.presets.microservicearchitecture.MicroserviceArchitecture) UpdateRulesConceptsAndRelationsRequestedEvent(org.archcnl.ui.inputview.presets.events.UpdateRulesConceptsAndRelationsRequestedEvent) HashSet(java.util.HashSet)

Aggregations

ArchitectureRuleConfig (org.archcnl.domain.input.model.presets.ArchitectureRuleConfig)3 HashSet (java.util.HashSet)2 Text (com.vaadin.flow.component.Text)1 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)1 Binder (com.vaadin.flow.data.binder.Binder)1 Set (java.util.Set)1 ArchitectureInformation (org.archcnl.domain.input.model.presets.ArchitectureInformation)1 MicroserviceArchitecture (org.archcnl.domain.input.model.presets.microservicearchitecture.MicroserviceArchitecture)1 MicroserviceArchitectureBuilder (org.archcnl.domain.input.model.presets.microservicearchitecture.MicroserviceArchitectureBuilder)1 UpdateRulesConceptsAndRelationsRequestedEvent (org.archcnl.ui.inputview.presets.events.UpdateRulesConceptsAndRelationsRequestedEvent)1