Пример #1
0
  /**
   * Parse Json Response from Alfresco REST API to create a process Definition Object.
   *
   * @param json : json response that contains data from the repository
   * @return ProcessDefinition Object
   */
  @SuppressWarnings("unchecked")
  public static Process parseJson(Map<String, Object> json) {
    ProcessImpl process = new ProcessImpl();

    // Public Properties
    process.identifier = JSONConverter.getString(json, OnPremiseConstant.ID_VALUE);
    String definitionIdentifier =
        JSONConverter.getString(json, OnPremiseConstant.DEFINITIONURL_VALUE);
    process.definitionIdentifier = definitionIdentifier.replace(SUFFIX_WORKFLOW_DEFINITION, "");
    process.key = JSONConverter.getString(json, OnPremiseConstant.NAME_VALUE);
    process.name = JSONConverter.getString(json, OnPremiseConstant.TITLE_VALUE);
    process.priority = JSONConverter.getInteger(json, OnPremiseConstant.PRIORITY_VALUE).intValue();
    process.description = JSONConverter.getString(json, OnPremiseConstant.MESSAGE_VALUE);

    // PARSE DATES
    String date = JSONConverter.getString(json, OnPremiseConstant.STARTDATE_VALUE);
    GregorianCalendar g = new GregorianCalendar();
    SimpleDateFormat sdf = new SimpleDateFormat(DateUtils.FORMAT_3, Locale.getDefault());
    if (date != null) {
      g.setTime(DateUtils.parseDate(date, sdf));
      process.startedAt = g;
    }

    date = JSONConverter.getString(json, OnPremiseConstant.ENDDATE_VALUE);
    if (date != null) {
      g = new GregorianCalendar();
      g.setTime(DateUtils.parseDate(date, sdf));
      process.endedAt = g;
    }

    // PARSE INITIATOR
    Map<String, Object> initiator =
        (Map<String, Object>) json.get(OnPremiseConstant.INITIATOR_VALUE);
    Person p = PersonImpl.parseJson(initiator);
    process.initiatorIdentifier = p.getIdentifier();

    // EXTRA PROPERTIES
    process.data = new HashMap<String, Serializable>();
    process.data.put(OnPremiseConstant.INITIATOR_VALUE, p);

    date = JSONConverter.getString(json, OnPremiseConstant.DUEDATE_VALUE);
    if (date != null) {
      g = new GregorianCalendar();
      g.setTime(DateUtils.parseDate(date, sdf));
      process.dueAt = g;
    }
    process.data.put(OnPremiseConstant.DUEDATE_VALUE, g);

    process.data.put(
        OnPremiseConstant.DESCRIPTION_VALUE,
        JSONConverter.getString(json, OnPremiseConstant.DESCRIPTION_VALUE));
    process.data.put(
        OnPremiseConstant.ISACTIVE_VALUE,
        JSONConverter.getBoolean(json, OnPremiseConstant.ISACTIVE_VALUE));

    process.hasAllVariables = true;

    return process;
  }
Пример #2
0
 /**
  * copy the person and the selected plan of the person
  *
  * @param person
  * @return
  */
 public static Person copyPerson(Person person) {
   Person newPerson = PersonImpl.createPerson(person.getId());
   PlanImpl newPlan = new PlanImpl();
   newPlan.copyFrom(person.getSelectedPlan());
   newPlan.setPerson(newPerson);
   newPerson.addPlan(newPlan);
   newPerson.setSelectedPlan(newPlan);
   PersonUtils.removeUnselectedPlans(newPerson);
   return newPerson;
 }
Пример #3
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public void eUnset(int featureID) {
   switch (featureID) {
     case EXTLibraryPackage.WRITER__NAME:
       setName(NAME_EDEFAULT);
       return;
     case EXTLibraryPackage.WRITER__BOOKS:
       getBooks().clear();
       return;
   }
   super.eUnset(featureID);
 }
Пример #4
0
  @Override
  public void init(XmlPullParser parser) throws IOException, XmlPullParserException {
    parser.require(XmlPullParser.START_TAG, null, null);

    while (parser.nextTag() == XmlPullParser.START_TAG) {
      String name = parser.getName();

      if (name.equals("id")) {
        setId(XppUtils.getElementValueFromNode(parser));
      } else if (name.equals("name")) {
        setName(XppUtils.getElementValueFromNode(parser));
      } else if (name.equals("person")) {
        PersonImpl author = new PersonImpl();
        author.init(parser);
        setPerson(author);
      } else {
        // Consume something we don't understand.
        LOG.warning("Found tag that we don't recognize: " + name);
        XppUtils.skipSubTree(parser);
      }
    }
  }
Пример #5
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @SuppressWarnings("unchecked")
 @Override
 public void eSet(int featureID, Object newValue) {
   switch (featureID) {
     case EXTLibraryPackage.WRITER__NAME:
       setName((String) newValue);
       return;
     case EXTLibraryPackage.WRITER__BOOKS:
       getBooks().clear();
       getBooks().addAll((Collection<? extends Book>) newValue);
       return;
   }
   super.eSet(featureID, newValue);
 }
Пример #6
0
 private void startPerson(final Attributes atts) {
   String ageString = atts.getValue("age");
   //		int age = Integer.MIN_VALUE;
   Integer age = null;
   if (ageString != null) age = Integer.parseInt(ageString);
   this.currperson = PersonImpl.createPerson(Id.create(atts.getValue("id"), Person.class));
   PersonUtils.setSex(this.currperson, atts.getValue("sex"));
   PersonUtils.setAge(this.currperson, age);
   PersonUtils.setLicence(this.currperson, atts.getValue("license"));
   PersonUtils.setCarAvail(this.currperson, atts.getValue("car_avail"));
   String employed = atts.getValue("employed");
   if (employed == null) {
     PersonUtils.setEmployed(this.currperson, null);
   } else {
     PersonUtils.setEmployed(this.currperson, "yes".equals(employed));
   }
 }