Examples of QuantityType


Examples of com.din.din.model.entities.QuantityType

  public static void createDefaultQuantityTypes(Project project, MeasurementSystem system, EntityCachingManager cache) {
    createDefaultQuantityTypes(null, project, system, cache);
  }
 
  protected static void createDefaultQuantityTypes(EntityManager entityManager, Project project, MeasurementSystem system, EntityCachingManager cache) {
    QuantityType type;
   
    boolean contained = false;
    if(entityManager == null) {
      contained = true;
      entityManager = EMFListener.get();
    }
    EntityTransaction transaction = entityManager.getTransaction();
    try {
      if(!transaction.isActive()) {
        contained = true;
        transaction.begin();
      }
      List<QuantityType> quantityTypes = getQuantityType(entityManager, project, null);
     
      if(quantityTypes == null || quantityTypes.size() == 0) {
        if(system == MeasurementSystem.Metric) {
          type = new QuantityType();
          type.setName("kg");
          type.setDescription(BeanUtil.getMessage("quantityType.kilograms"));
          type.setType(MeasurementType.Weight);
          type.setProject(project);
          save(entityManager, type, cache);
         
          type = new QuantityType();
          type.setName("hg");
          type.setDescription(BeanUtil.getMessage("quantityType.hectograms"));
          type.setType(MeasurementType.Weight);
          type.setProject(project);
          save(entityManager, type, cache);   
         
          type = new QuantityType();
          type.setName("g");
          type.setDescription(BeanUtil.getMessage("quantityType.grams"));
          type.setType(MeasurementType.Weight);
          type.setProject(project);
          save(entityManager, type, cache);
         
          type = new QuantityType();
          type.setName("L");
          type.setDescription(BeanUtil.getMessage("quantityType.liters"));
          type.setType(MeasurementType.Volume);
          type.setProject(project);
          save(entityManager, type, cache);
         
          type = new QuantityType();
          type.setName("mL");
          type.setDescription(BeanUtil.getMessage("quantityType.milliliters"));
          type.setType(MeasurementType.Volume);
          type.setProject(project);
          save(entityManager, type, cache)
        } else {
          type = new QuantityType();
          type.setName("oz.");
          type.setDescription(BeanUtil.getMessage("quantityType.ounces"));
          type.setType(MeasurementType.Weight);
          type.setProject(project);
          save(entityManager, type, cache)
         
          type = new QuantityType();
          type.setName("lbs.");
          type.setDescription(BeanUtil.getMessage("quantityType.pounds"));
          type.setType(MeasurementType.Weight);
          type.setProject(project);
          save(entityManager, type, cache)
         
          type = new QuantityType();
          type.setName("gal.");
          type.setDescription(BeanUtil.getMessage("quantityType.gallons"));
          type.setType(MeasurementType.Volume);
          type.setProject(project);
          save(entityManager, type, cache);
         
          type = new QuantityType();
          type.setName("qt.");
          type.setDescription(BeanUtil.getMessage("quantityType.quarts"));
          type.setType(MeasurementType.Volume);
          type.setProject(project);
          save(entityManager, type, cache);
         
          type = new QuantityType();
          type.setName("fl. oz.");
          type.setDescription(BeanUtil.getMessage("quantityType.fluidOunces"));
          type.setType(MeasurementType.Volume);
          type.setProject(project);
          save(entityManager, type, cache);   
         
          type = new QuantityType();
          type.setName("c");
          type.setDescription(BeanUtil.getMessage("quantityType.cups"));
          type.setType(MeasurementType.Volume);
          type.setProject(project);
          save(entityManager, type, cache)
         
          type = new QuantityType();
          type.setName("tsp.");
          type.setDescription(BeanUtil.getMessage("quantityType.teaspoons"));
          type.setType(MeasurementType.Volume);
          type.setProject(project);
          save(entityManager, type, cache)
         
          type = new QuantityType();
          type.setName("tbsp.");
          type.setDescription(BeanUtil.getMessage("quantityType.tablespoons"));
          type.setType(MeasurementType.Volume);
          type.setProject(project);
          save(entityManager, type, cache);   
        }
        type = new QuantityType();
        type.setName(BeanUtil.getMessage("quantityType.pieces"));
        type.setDescription(BeanUtil.getMessage("quantityType.pieces"));
        type.setType(MeasurementType.Quantity);
        type.setProject(project);
        type.setRemoveable(false);
        save(entityManager, type, cache);         
      }
      if(contained) {
        transaction.commit();
      }
View Full Code Here

Examples of com.din.din.model.entities.QuantityType

 
  /**
   * Intelligently attempt to fill in the blanks on some values
   */
  private void loadDefaults() {
    QuantityType piecesType = null;
    try {
      List<KeyEntity> quantityTypes = cache.getListBy(QuantityType.class, "type", MeasurementType.Quantity, "project", project);
      for(KeyEntity entity : quantityTypes) {
        QuantityType qt = (QuantityType)entity;
        if(qt.isRemoveable()) {
          piecesType = qt;
        }
      }
      if(piecesType != null) {
        recipeItem.setQuantityTypeKey(piecesType.getKey());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.