@Override
 protected final void updateItem(LocalFile item, boolean empty) {
   super.updateItem(item, empty);
   icon.set(null);
   title.setValue("");
   if (!empty) {
     icon.set(item.getIcon());
     title.setValue(item.getFileName());
   }
 }
  public String resolveEquals(DataObject dataObject, String indent) {

    StringBuilder head = new StringBuilder();
    // head.append(EOL);
    head.append(indent + "@Override" + EOL);
    head.append(indent + "public boolean equals(Object o) {" + EOL);
    head.append(indent + TAB + "if (this == o) return true;" + EOL);
    head.append(indent + TAB + "if (o == null || getClass() != o.getClass()) return false;" + EOL);
    head.append(
        indent
            + TAB
            + dataObject.getClassName()
            + " that = ("
            + dataObject.getClassName()
            + ")o;"
            + EOL);

    StringBuilder end = new StringBuilder();
    end.append(indent + "}");

    StringBuilder sb = new StringBuilder();
    Map<String, ObjectProperty> props = dataObject.getProperties();

    boolean hasTerms = false;
    if (props != null && props.size() > 0) {
      for (String propName : props.keySet()) {
        ObjectProperty prop = props.get(propName);
        String _propName = toJavaVar(propName);
        if (prop.getAnnotation(org.kie.api.definition.type.Key.class.getName()) != null) {
          // Construction: "if (<_propName> != null ? !<_propName>.equals(that.<_propName>) :
          // that.<_propName> != null) return false;"
          sb.append(indent + TAB + "if (");
          sb.append(_propName)
              .append(" != null ? !")
              .append(_propName)
              .append(".equals(that.")
              .append(_propName)
              .append(")");
          sb.append(" : that.").append(_propName).append(" != null").append(") return false;");
          sb.append(EOL);
          hasTerms = true;
        }
      }
    }

    if (hasTerms) {
      sb.append(indent + TAB + "return true;" + EOL);
      head.append(sb);
      head.append(end);
      return head.toString();
    } else {
      return "";
    }
  }
 public String resolveKeyFieldsConstructor(DataObject dataObject, String indent) {
   if (!dataObject.getProperties().isEmpty()) {
     List<ObjectProperty> sortedProperties = new ArrayList<ObjectProperty>();
     for (ObjectProperty property : dataObject.getProperties().values()) {
       if (property.getAnnotation(KeyAnnotationDefinition.getInstance().getClassName()) != null) {
         // the property is marked as key.
         sortedProperties.add(property);
       }
     }
     if (sortedProperties.size() > 0
         && sortedProperties.size() < dataObject.getProperties().size()) {
       return resolveConstructor(dataObject, sortByPosition(sortedProperties), indent);
     }
   }
   return "";
 }
  public String resolveHashCode(DataObject dataObject, String indent) {

    StringBuilder head = new StringBuilder();
    // head.append(EOL);
    head.append(indent + "@Override" + EOL);
    head.append(indent + "public int hashCode() {" + EOL);
    head.append(indent + TAB + "int result = 17;" + EOL);

    StringBuilder end = new StringBuilder();
    end.append(indent + "}");

    StringBuilder sb = new StringBuilder();
    Map<String, ObjectProperty> props = dataObject.getProperties();

    boolean hasTerms = false;
    if (props != null && props.size() > 0) {
      for (String propName : props.keySet()) {
        ObjectProperty prop = props.get(propName);
        String _propName = toJavaVar(propName);
        if (prop.getAnnotation(org.kie.api.definition.type.Key.class.getName()) != null) {
          // Construction: "result = 13 * result + (<_propName> != null ? <_propName>.hashCode() :
          // 0);"
          sb.append(indent + TAB + "result = 13 * result + (")
              .append(_propName)
              .append(" != null ? ")
              .append(_propName)
              .append(".hashCode() : 0);");
          sb.append(EOL);
          hasTerms = true;
        }
      }
    }

    if (hasTerms) {
      sb.append(indent + TAB + "return result;" + EOL);
      head.append(sb);
      head.append(end);
      return head.toString();
    } else {
      return "";
    }
  }
  public String resolveConstructor(
      DataObject dataObject, List<ObjectProperty> properties, String indent) {

    StringBuilder head = new StringBuilder();
    StringBuilder body = new StringBuilder();

    head.append(indent + "public " + dataObject.getName() + "(");

    if (properties != null && properties.size() > 0) {
      boolean isFirst = true;
      String propertyName;
      for (ObjectProperty property : properties) {
        if (!isFirst) {
          head.append(", ");
          body.append(EOL);
        }
        propertyName = toJavaVar(property.getName());
        head.append(resolveAttributeType(property));
        head.append(" ");
        head.append(propertyName);

        body.append(indent);
        body.append(indent);
        body.append("this.");
        body.append(propertyName);
        body.append(" = ");
        body.append(propertyName);
        body.append(";");

        isFirst = false;
      }
      body.append(EOL);
    }

    head.append(") {" + EOL);
    head.append(body);
    head.append(indent + "}");

    return head.toString();
  }
 public String resolveAttributeType(ObjectProperty attribute) {
   StringBuffer type = new StringBuffer("");
   if (attribute.isMultiple()) {
     if (attribute.getBag() != null && !"".equals(attribute.getBag())) {
       type.append(attribute.getBag());
     } else {
       type.append("java.util.List");
     }
     type.append("<");
   }
   type.append(attribute.getClassName());
   if (attribute.isMultiple()) {
     type.append(">");
   }
   return type.toString();
 }
Esempio n. 7
0
 public Person getScrumMaster() {
   return scrumMaster.get();
 }
Esempio n. 8
0
 public Person getProductOwner() {
   return productOwner.get();
 }