Example #1
0
    @Override
    @Transactional(readOnly=true)
    public void addMaterialCategory(MaterialCategory parent, String categoryName) throws ValidationException {
        Validate.notNull(categoryName);

        Boolean generateCode = configurationDAO.getConfiguration()
                .getGenerateCodeForMaterialCategories();
        MaterialCategory child = MaterialCategory.createUnvalidated("",
                _(categoryName));
        if (generateCode) {
            setCurrentMaterialCategory(child);
            setDefaultCode();
        }
        child.setCodeAutogenerated(generateCode);

        final MaterialCategory materialCategory = findMaterialCategory(child);
        if (materialCategory != null) {
            throw new ValidationException(invalidValue(
                    _("{0} already exists", materialCategory.getName()),
                    "name", materialCategory.getName(), materialCategory));
        }

        child.setParent(parent);
        if (parent == null) {
            materialCategories.addToRoot(child);
        } else {
            materialCategories.add(parent, child);
        }
    }
Example #2
0
    @Override
    @Transactional(readOnly = true)
    public void initCreate() {
        editing = false;

        boolean codeGenerated = (configurationDAO.getConfiguration() != null) ? configurationDAO
                .getConfiguration().getGenerateCodeForBaseCalendars()
                : false;

        this.baseCalendar = BaseCalendar.createBasicCalendar("");

        if (codeGenerated) {
            setDefaultCode();
        }
        baseCalendar.setCodeAutogenerated(codeGenerated);
    }
Example #3
0
 private void checkIsPersonalTimesheetsTypeOfWorkHours(TypeOfWorkHours type) {
   Configuration configuration = configurationDAO.getConfiguration();
   if (configuration.getPersonalTimesheetsTypeOfWorkHours().getId().equals(type.getId())) {
     throw ValidationException.invalidValueException(
         "Cannot delete the type of work hours. It is configured as type of work hours for personal timesheets.",
         type);
   }
 }
Example #4
0
    @Override
    @Transactional(readOnly = true)
    public void initCreateDerived(BaseCalendar baseCalendar) {
        editing = false;
        Validate.notNull(baseCalendar);

        this.baseCalendar = getFromDB(baseCalendar).newDerivedCalendar();
        forceLoad(this.baseCalendar);
        this.baseCalendar.setCode("");

        boolean codeGenerated = (configurationDAO.getConfiguration() != null) ? configurationDAO
                .getConfiguration().getGenerateCodeForBaseCalendars()
                : false;

        if (codeGenerated) {
            setDefaultCode();
        }
        this.baseCalendar.setCodeAutogenerated(codeGenerated);
    }
  private Order givenValidOrderAlreadyStored() {
    Order order = Order.create();
    order.setCode(UUID.randomUUID().toString());
    order.setName("Order name " + UUID.randomUUID());
    order.setInitDate(new Date());
    order.setCalendar(configurationDAO.getConfiguration().getDefaultCalendar());
    OrderVersion version = setupVersionUsing(scenarioManager, order);
    order.useSchedulingDataFor(version);

    orderDAO.save(order);
    orderDAO.flush();
    try {
      return orderDAO.find(order.getId());
    } catch (InstanceNotFoundException e) {
      return null;
    }
  }
Example #6
0
 @Override
 @Transactional(readOnly = true)
 public boolean isDefaultCalendar(BaseCalendar baseCalendar) {
     Configuration configuration = configurationDAO.getConfiguration();
     if (configuration == null) {
         return false;
     }
     BaseCalendar defaultCalendar = configuration.getDefaultCalendar();
     if (defaultCalendar == null) {
         return false;
     }
     if (baseCalendar == null) {
         return false;
     }
     return baseCalendar.getId().equals(
             defaultCalendar
                     .getId());
 }