use of com.qcadoo.mes.technologies.domain.TechnologyId in project mes by qcadoo.
the class TechnologyProductsCustomizerTest method shouldFailDueToOutputOperationComponentValidationErrors.
@Test
@Ignore
public final void shouldFailDueToOutputOperationComponentValidationErrors() {
// given
Entity technology = mockEntity(TECH_ID, true);
stubTechnologyLookup(technology);
Long mainOpocId = 100L;
Entity mainOutputProductComponent = mockEntity(mainOpocId, true);
stubMainOutputProductComponentLookup(mainOutputProductComponent);
Entity opoc = mockOutputComponent(300L, false, EntityTestUtils.mockEntity());
stubOutputComponents(opoc);
// when
Either<String, TechnologyId> result = technologyProductsCustomizer.customize(technologyId, mainProduct, newProduct, generatorSettings);
// then
Assert.assertTrue(result.isLeft());
Assert.assertEquals(productComponentValidationErrorMessage(opoc), result.getLeft());
}
use of com.qcadoo.mes.technologies.domain.TechnologyId in project mes by qcadoo.
the class TechnologyStructureTreeDataProvider method buildProductInfo.
private ProductInfo buildProductInfo(final Entity projection, final Map<ProductId, TechnologyId> defaultTechnologies) {
Optional<OperationProductInComponentId> opicId = Optional.ofNullable((Long) projection.getField("opicId")).map(OperationProductInComponentId::new);
TechnologyOperationId tocId = new TechnologyOperationId((Long) projection.getField("tocId"));
Optional<TechnologyOperationId> parentId = Optional.ofNullable((Long) projection.getField("parentId")).map(TechnologyOperationId::new);
ProductId productId = buildProduct(projection);
Optional<TechnologyId> prodTechnology = Optional.ofNullable(defaultTechnologies.get(productId));
Optional<TechnologyInputProductTypeId> technologyInputProductType = Optional.ofNullable((Long) projection.getField("technologyInputProductTypeId")).map(TechnologyInputProductTypeId::new);
boolean differentProductsInDifferentSizes = projection.getBooleanField("differentProductsInDifferentSizes");
boolean variousQuantitiesInProductsBySize = projection.getBooleanField("variousQuantitiesInProductsBySize");
OperationId operation = buildOperation(projection);
BigDecimal quantity = projection.getDecimalField("quantity");
boolean isIntermediate = projection.getBooleanField("isIntermediate");
String givenUnit = projection.getStringField("givenUnit");
Optional<SizeGroupId> sizeGroup = Optional.ofNullable((Long) projection.getField("sizeGroupId")).map(SizeGroupId::new);
return new ProductInfo(opicId, tocId, parentId, productId, quantity, prodTechnology, prodTechnology, technologyInputProductType, differentProductsInDifferentSizes, variousQuantitiesInProductsBySize, operation, isIntermediate, givenUnit, sizeGroup);
}
use of com.qcadoo.mes.technologies.domain.TechnologyId in project mes by qcadoo.
the class TechnologyStructureTreeDataProvider method findExistingCustomizedNodes.
public Map<TechnologyId, Entity> findExistingCustomizedNodes(final ContextId contextId) {
if (Objects.isNull(contextId)) {
return ImmutableMap.of();
}
SearchCriteriaBuilder scb = prepareExistingNodeSearchCriteria(contextId);
List<Entity> existingNodes = scb.list().getEntities();
return ImmutableMap.copyOf(Maps.uniqueIndex(existingNodes, n -> new TechnologyId(n.getBelongsToField(GeneratorTreeNodeFields.ORIGINAL_TECHNOLOGY).getId())));
}
use of com.qcadoo.mes.technologies.domain.TechnologyId in project mes by qcadoo.
the class TechnologiesGeneratorForProductsService method setupTechnologyNumberAndName.
private Either<String, TechnologyId> setupTechnologyNumberAndName(final GeneratorSettings settings, final Entity technology, final Entity product) {
technology.setField("generatorContext", settings.getGenerationContext());
technology.setField(TechnologyFields.NUMBER, technologyNameAndNumberGenerator.generateNumber(product));
technology.setField(TechnologyFields.NAME, technologyNameAndNumberGenerator.generateName(product));
Entity savedTech = technology.getDataDefinition().save(technology);
if (savedTech.isValid()) {
LOG.info(String.format("Generated technology with number : %S", technology.getStringField(TechnologyFields.NUMBER)));
return Either.right(new TechnologyId(savedTech.getId()));
} else {
return Either.left("Cannot setup technology name and number due to validation errors");
}
}
use of com.qcadoo.mes.technologies.domain.TechnologyId in project mes by qcadoo.
the class TechnologyCustomizer method setupTechnologyNumberAndName.
private Either<String, TechnologyId> setupTechnologyNumberAndName(final Entity technology, final Entity product) {
technology.setField(TechnologyFields.NUMBER, technologyNameAndNumberGenerator.generateNumber(product));
technology.setField(TechnologyFields.NAME, technologyNameAndNumberGenerator.generateName(product));
Entity savedTech = technology.getDataDefinition().save(technology);
if (savedTech.isValid()) {
return Either.right(new TechnologyId(savedTech.getId()));
} else {
return Either.left("Cannot setup technology name and number due to validation errors");
}
}
Aggregations