@Override
  public boolean isCurrentUnitType(Object assignment, UnitType unitType) {
    MaterialAssignmentTemplate material = (MaterialAssignmentTemplate) assignment;

    return ((material != null)
        && (material.getMaterial().getUnitType() != null)
        && (unitType.getId().equals(material.getMaterial().getUnitType().getId())));
  }
 private void initializeMaterialAssignments(
     Collection<MaterialAssignmentTemplate> materialAssignments) {
   for (MaterialAssignmentTemplate each : materialAssignments) {
     each.getUnits();
     reattachMaterial(each.getMaterial());
     initializeMaterialCategory(each.getMaterial().getCategory());
   }
 }
 @Override
 @Transactional(readOnly = true)
 public void addMaterialAssignment(Material material) {
   MaterialAssignmentTemplate materialAssignmentTemplate =
       MaterialAssignmentTemplate.create(template, material);
   addMaterialAssignment(materialAssignmentTemplate);
 }
 @Override
 protected BigDecimal getUnits(MaterialAssignmentTemplate assignment) {
   return assignment.getUnits();
 }
 @Override
 protected BigDecimal getTotalPrice(MaterialAssignmentTemplate each) {
   return each.getTotalPrice();
 }
 @Override
 protected Material getMaterial(MaterialAssignmentTemplate assignment) {
   return assignment.getMaterial();
 }
 @Override
 protected MaterialCategory addAssignment(MaterialAssignmentTemplate materialAssignment) {
   template.addMaterialAssignment(materialAssignment);
   return materialAssignment.getMaterial().getCategory();
 }