Search in sources :

Example 1 with GeneratorView

use of com.qcadoo.mes.technologiesGenerator.view.GeneratorView in project mes by qcadoo.

the class GeneratorViewListeners method generateTechnologies.

public void generateTechnologies(final ViewDefinitionState view, final ComponentState eventPerformer, final String[] args) {
    GeneratorView generatorView = GeneratorView.from(view);
    Entity context = generatorView.getFormEntity().getDataDefinition().get(generatorView.getFormEntity().getId());
    context.setField(GeneratorContextFields.GENERATION_IN_PROGRSS, true);
    context = context.getDataDefinition().save(context);
    generatorView.setFormEntity(context);
    view.addMessage("generator.technology.generationTechnologyStart", ComponentState.MessageType.INFO, false);
    technologiesGeneratorForProductsService.performGeneration(generatorView);
}
Also used : Entity(com.qcadoo.model.api.Entity) GeneratorView(com.qcadoo.mes.technologiesGenerator.view.GeneratorView)

Example 2 with GeneratorView

use of com.qcadoo.mes.technologiesGenerator.view.GeneratorView in project mes by qcadoo.

the class GeneratorViewHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    GeneratorView generatorView = GeneratorView.from(view);
    generateProductNumber(view);
    showRibbonButtons(generatorView, view);
    GridComponent grid = (GridComponent) view.getComponentByReference("generatorTechnologiesForProducts");
    FilterValueHolder gridHolder = grid.getFilterValue();
    gridHolder.put(TechnologiesForProductsCM.PARAMETER, generatorView.getFormEntity().getId());
    grid.setFilterValue(gridHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) GridComponent(com.qcadoo.view.api.components.GridComponent) GeneratorView(com.qcadoo.mes.technologiesGenerator.view.GeneratorView)

Example 3 with GeneratorView

use of com.qcadoo.mes.technologiesGenerator.view.GeneratorView in project mes by qcadoo.

the class GeneratorViewListeners method tryPerformCustomization.

private Optional<Either<String, TechnologyId>> tryPerformCustomization(final GeneratorView generatorView, final Entity context) {
    try {
        Optional<Either<String, TechnologyId>> customizedTechId = Optional.ofNullable(context.getBelongsToField(GeneratorContextFields.PRODUCT)).flatMap(mainProduct -> generatorView.getSelectedNodeId().flatMap(nodeId -> technologyCustomizer.customize(nodeId, mainProduct, GeneratorSettings.from(context, parameterService.getParameter()), false)));
        customizedTechId.ifPresent(cti -> {
            if (cti.isRight()) {
                TechnologyId technologyId = cti.getRight();
                technologyCustomizer.addCustomizedProductToQualityCard(technologyId);
            }
        });
        return customizedTechId;
    } catch (Exception e) {
        if (LOGGER.isWarnEnabled()) {
            LOGGER.warn("Cannot perform technology customization due to unexpected error", e);
        }
        return Optional.of(Either.left("Cannot perform technology customization due to unexpected error"));
    }
}
Also used : TechnologiesGeneratorForProductsService(com.qcadoo.mes.technologiesGenerator.TechnologiesGeneratorForProductsService) TechnologyCustomizer(com.qcadoo.mes.technologiesGenerator.customization.technology.TechnologyCustomizer) Logger(org.slf4j.Logger) ImmutableMap(com.google.common.collect.ImmutableMap) GeneratorContextFields(com.qcadoo.mes.technologiesGenerator.constants.GeneratorContextFields) ComponentState(com.qcadoo.view.api.ComponentState) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) GeneratorSettings(com.qcadoo.mes.technologiesGenerator.GeneratorSettings) ContextId(com.qcadoo.mes.technologiesGenerator.domain.ContextId) GridComponent(com.qcadoo.view.api.components.GridComponent) TreeGenerator(com.qcadoo.mes.technologiesGenerator.tree.TreeGenerator) Entity(com.qcadoo.model.api.Entity) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) ParameterService(com.qcadoo.mes.basic.ParameterService) GeneratorView(com.qcadoo.mes.technologiesGenerator.view.GeneratorView) Service(org.springframework.stereotype.Service) Either(com.qcadoo.commons.functional.Either) Optional(java.util.Optional) TechnologyId(com.qcadoo.mes.technologies.domain.TechnologyId) TechnologyId(com.qcadoo.mes.technologies.domain.TechnologyId) Either(com.qcadoo.commons.functional.Either)

Example 4 with GeneratorView

use of com.qcadoo.mes.technologiesGenerator.view.GeneratorView in project mes by qcadoo.

the class GeneratorViewListeners method generateTree.

public void generateTree(final ViewDefinitionState view, final ComponentState eventPerformer, final String[] args) {
    GeneratorView generatorView = GeneratorView.from(view);
    Either<String, ContextId> generationResults = generate(generatorView, false);
    if (generationResults.isRight()) {
        generatorView.showStructureTreeTab();
    }
}
Also used : ContextId(com.qcadoo.mes.technologiesGenerator.domain.ContextId) GeneratorView(com.qcadoo.mes.technologiesGenerator.view.GeneratorView)

Aggregations

GeneratorView (com.qcadoo.mes.technologiesGenerator.view.GeneratorView)4 ContextId (com.qcadoo.mes.technologiesGenerator.domain.ContextId)2 Entity (com.qcadoo.model.api.Entity)2 GridComponent (com.qcadoo.view.api.components.GridComponent)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Either (com.qcadoo.commons.functional.Either)1 ParameterService (com.qcadoo.mes.basic.ParameterService)1 TechnologyId (com.qcadoo.mes.technologies.domain.TechnologyId)1 GeneratorSettings (com.qcadoo.mes.technologiesGenerator.GeneratorSettings)1 TechnologiesGeneratorForProductsService (com.qcadoo.mes.technologiesGenerator.TechnologiesGeneratorForProductsService)1 GeneratorContextFields (com.qcadoo.mes.technologiesGenerator.constants.GeneratorContextFields)1 TechnologyCustomizer (com.qcadoo.mes.technologiesGenerator.customization.technology.TechnologyCustomizer)1 TreeGenerator (com.qcadoo.mes.technologiesGenerator.tree.TreeGenerator)1 ComponentState (com.qcadoo.view.api.ComponentState)1 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)1 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)1 Optional (java.util.Optional)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1