Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Code Block
entity.getBelongsToField(PluginNameFields.ORDER);

or even better:

Code Block
import static com.qcadoo.mes.pluginName.constants.PluginNameFields;
 
entity.getBelongstoField(ORDER);

I know it's something new, and refactoring the whole system will be a horror. Let's just use it from now on, ok?You should avoid static importing such constants or you loose their namespace and the probability to make mistake increase dramatically.
It is important especially for field names, which often has the same (or at least very similar) names.

 

Java enums

For every enum field of a model we create, we should create corresponding Java enum in constants package.

...

Code Block
titleBatchNumberUniquness.java
public enum BatchNumberUniqueness {
 
  GLOBALLY("01globally"), MANUFACTURER("02manufacturer");

  private final String stringValue;
 
  private BatchNumberUniqueness(final String stringValue) {
    this.stringValue = stringValue;
  }
  
  public String getStringValue() {
    return stringValue;
  }

  public static BatchNumberUniqueness parseString(final String string) {
    if (GLOBALLY.getStringValue().equals(string))BatchNumberUniqueness parsedEnum = null;
      for (BatchNumberUniqueness value : BatchNumberUniqueness.values()) {
      return GLOBALLY;
    } else if (MANUFACTURERvalue.getStringValue().equals(string)) {
          parsedEnum = value;
       return   MANUFACTURERbreak;
        }
 else {    }
  throw new IllegalArgumentException(Preconditions.checkArgument(parsedEnum != null, "Couldn't parse BatchNumberUniquenessenum from string '" + string + "'");
    }return parsedEnum;
  }

  @Override
  public String toString() {
    return stringValue;
  }

}

...

  • constants - we hold here classes like AwesomePluginConstants AwesomePluginConstants.java and maybe some model enums that are plugin specific.
  • hooks - model and view hooks like: ViewNameHooks ViewNameHooks.java, ModelNameHooks ModelNameHooks.java. If the hook class is meant to extend (on a business level) an other plugin it should have plugin abbreviation for ex. ModelNameHooksAP ModelNameHooksAP.java
  • validators - model validators like: ModelNameValidators ModelNameValidators.java, SomeOtherModelNameValidators SomeOtherModelNameValidators.java or ModelNameValidatorsAP ModelNameValidatorsAP.java (like with the hooks)
  • listeners - view listeners like: ViewNameListeners ViewNameListeners.java, ViewNameListenersAP ViewNameListenersAP.java (like with the hooks)states - if there is some logic regarding model states (I consider enum state model field as something that common to write it here), for ex. ModelNameStatesService.java
  • workPlansColumnExtensionhttp://wiki.qcadoo.org/display/QCDMESDOC/WorkPlans+column+extension

...