public void setOccupationTypeToDefault(final ViewDefinitionState view) {
    FormComponent staffAssignmentToShiftForm = (FormComponent) view.getComponentByReference("form");
    FieldComponent occupationType = (FieldComponent) view.getComponentByReference(OCCUPATION_TYPE);

    if ((staffAssignmentToShiftForm.getEntityId() == null)
        && (occupationType.getFieldValue() == null)) {
      Entity dictionaryItem = findDictionaryItemByTechnicalCode(WORK_ON_LINE.getStringValue());

      if (dictionaryItem != null) {
        String occupationTypeName = dictionaryItem.getStringField(NAME);

        occupationType.setFieldValue(occupationTypeName);
        occupationType.requestComponentUpdateState();
      }
    }
  }
  private void checkIfProductionLineFilled(
      DataDefinition multiAssignmentToShiftDD, Entity multiAssignmentToShift) {
    if (multiAssignmentToShift.getId() != null) {
      String occupationType =
          multiAssignmentToShift.getStringField(MultiAssignmentToShiftFields.OCCUPATION_TYPE);

      Entity dictionaryItem = findDictionaryItemByName(occupationType);

      String technicalCode = dictionaryItem.getStringField(TECHNICAL_CODE);

      if (technicalCode != null && technicalCode.equals(WORK_ON_LINE.getStringValue())) {
        if (multiAssignmentToShift.getBelongsToField(MultiAssignmentToShiftFields.PRODUCTION_LINE)
            == null) {
          multiAssignmentToShift.addError(
              multiAssignmentToShiftDD.getField(MultiAssignmentToShiftFields.PRODUCTION_LINE),
              "assignmentToShift.staffAssignmentToShift.productionLine.isEmpty");
        }
      }
    }
  }
  public void setFieldsEnabledWhenTypeIsSpecific(final ViewDefinitionState view) {
    FieldComponent occupationType = (FieldComponent) view.getComponentByReference(OCCUPATION_TYPE);

    if (occupationType.getFieldValue() != null) {
      Entity dictionaryItem = findDictionaryItemByName(occupationType.getFieldValue().toString());
      if (dictionaryItem == null) {
        setFieldsEnabled(view, false, false);
      } else {
        String occupationTypeTechnicalCode = dictionaryItem.getStringField(TECHNICAL_CODE);

        if (WORK_ON_LINE.getStringValue().equals(occupationTypeTechnicalCode)) {
          setFieldsEnabled(view, true, false);
        } else if (OTHER_CASE.getStringValue().equals(occupationTypeTechnicalCode)) {
          setFieldsEnabled(view, false, true);
        } else {
          setFieldsEnabled(view, false, false);
        }
      }
    }
  }