return DirectCriterionRequirement.create(criterion);
}
public final static MaterialAssignment toEntity(
MaterialAssignmentDTO materialAssignmentDTO) {
Material material = null;
try {
material = Registry.getMaterialDAO()
.findUniqueByCodeInAnotherTransaction(
materialAssignmentDTO.materialCode);
} catch (InstanceNotFoundException e) {
material = Material.create(materialAssignmentDTO.materialCode);
material.setDescription("material-"
+ materialAssignmentDTO.materialCode);
MaterialCategory defaultMaterialCategory = PredefinedMaterialCategories.IMPORTED_MATERIALS_WITHOUT_CATEGORY
.getMaterialCategory();
material.setCategory(defaultMaterialCategory);
/*
* "validate" method avoids that "material" goes to the Hibernate's
* session if "material" is not valid.
*/
material.validate();
Registry.getMaterialDAO().save(material);
material.dontPoseAsTransientObjectAnymore();
}
MaterialAssignment materialAssignment = MaterialAssignment
.create(material);
materialAssignment