Exemplo n.º 1
0
  /**
   * Creates a new Property Group object, sets its name, and fires the add group method that takes a
   * group object as a first argument. This method makes other methods easier to read and
   * understand.
   *
   * @param ofName The name of the group to be created
   * @param to The parent group the new group will be added to
   */
  private void _addGroup(String ofName, PropertyGroup to) {
    PropertyGroup group = new PropertyGroup();
    group.setName(ofName);
    recent = group;

    _addGroup(group, to);
  }
Exemplo n.º 2
0
 private void removeFromAllValidIfNeeded(E element) {
   if (allValid != null) {
     if (element instanceof Property<?>) {
       allValid.remove((Property<?>) element);
     } else if (element instanceof Model) {
       allValid.remove(((Model) element).allValid());
     }
   }
 }
Exemplo n.º 3
0
 private void addToAllValidIfNeeded(E element) {
   if (allValid != null) {
     if (element instanceof Property<?>) {
       allValid.add((Property<?>) element);
     } else if (element instanceof Model) {
       allValid.add(((Model) element).allValid());
     }
   }
 }
Exemplo n.º 4
0
 /**
  * Finds the list of data objects that are associated with properties in this template.
  *
  * @return the list of referenced data objects.
  */
 public List<DataObject> findReferencedDataObjects() {
   List<DataObject> result = new ArrayList<DataObject>();
   for (PropertyGroup propertyGroup : getPropertyGroups()) {
     for (Property property : propertyGroup.getProperties()) {
       DataObject dataObject = property.getDataObject();
       if (dataObject != null) {
         result.add(dataObject);
       }
     }
   }
   return result;
 }
Exemplo n.º 5
0
  /** {@inheritDoc} */
  @Override
  public void accept(BaseTemplateMarshaller marshaller) throws WorkflowException {
    try {
      marshaller.visit(this);

      marshaller.visitInputs(inputs);
      marshaller.leaveInputs(inputs);

      for (PropertyGroup propertyGroup : propertyGroups) {
        propertyGroup.accept(marshaller);
      }
      marshaller.leave(this);
    } catch (Exception ex) {
      throw new WorkflowException(ex.getMessage(), ex);
    }
  }
Exemplo n.º 6
0
  /**
   * Creates a new Property Pool object and performs the initial set up.
   *
   * <p>The initial set up consists of instantiating the history stack, creating a new Property
   * Group object to be used as the parent group, and then pushing this new group to the top of the
   * currently empty history stack.
   *
   * <p>This ensures that any added base-level Property Groups will not be met with an empty history
   * stack and no parent to attach themselves to.
   */
  public PropertyPool() {
    history = new Stack<PropertyGroup>();

    parent = new PropertyGroup();
    parent.setName("parent");

    history.push(parent);
  }
Exemplo n.º 7
0
 public JailProperty(
     String outsideName, String jailName, PropertyGroup group, int jailFee, int doubleAttempts) {
   super(outsideName);
   this.jailName = jailName;
   this.group = group;
   this.jailFee = jailFee;
   this.doubleAttempts = doubleAttempts;
   group.addProperty(this);
 }
Exemplo n.º 8
0
 /**
  * @return a property that, if we contain properties or models, will be true if all contains
  *     properties/models (as well as ourself) are valid.
  */
 public Property<Boolean> allValid() {
   if (allValid == null) {
     allValid = new PropertyGroup(getValueObject().getName() + ".allValid");
     allValid.add(this);
     for (E element : getDirect()) {
       addToAllValidIfNeeded(element);
     }
   }
   return allValid;
 }
Exemplo n.º 9
0
  /**
   * Creates a new XML document from the Property Poo's structure and content.
   *
   * @return An XML document representing the Property Pool
   */
  public Document toXMLDocument() {
    try {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      DocumentBuilder builder = factory.newDocumentBuilder();

      Document doc = builder.newDocument();

      /* Get the base parent group */
      PropertyGroup parentGroup = getParent();

      /* Create XML element for the parent group and append it to the XML document */
      // Element parent = doc.createElement("DOC_DIRECT_CHILD");
      // doc.appendChild(parent);

      /* Start chain reaction of writing functions */

      parentGroup.write(doc, null);

      return doc;
    } catch (ParserConfigurationException e) {
      e.printStackTrace();
      return null;
    }
  }
Exemplo n.º 10
0
 public PropertyGroup removeLocalPG(PropertyGroup pg) {
   Class pgc = pg.getPrimaryClass();
   if (AirLiftPG.class.equals(pgc)) {
     PropertyGroup removed = myAirLiftPG;
     myAirLiftPG = null;
     return removed;
   } else if (AirVehiclePG.class.equals(pgc)) {
     PropertyGroup removed = myAirVehiclePG;
     myAirVehiclePG = null;
     return removed;
   } else if (AirSelfPropulsionPG.class.equals(pgc)) {
     PropertyGroup removed = myAirSelfPropulsionPG;
     myAirSelfPropulsionPG = null;
     return removed;
   } else {
   }
   return super.removeLocalPG(pg);
 }
Exemplo n.º 11
0
 /**
  * Adds the new group as a child of the current group, which is the group located on the top of
  * the history stack, and then pushes this new group to the top of the history stack, thus making
  * it the new current group.
  *
  * @param group The group to be added
  * @param to The parent group the new group will be added to
  */
 private void _addGroup(PropertyGroup group, PropertyGroup to) {
   group.setParent(history.peek());
   history.peek().addChild(group);
   history.push(group);
 }
Exemplo n.º 12
0
 /** Visualizes and prints the structure currently held by the Property Pool. */
 public void show() {
   parent.print(0);
 }
Exemplo n.º 13
0
 public T in(final PropertyGroup group) {
   group.add(this);
   return getThis();
 }