Ejemplo n.º 1
0
 /*
  * Gets the Author Information for a specific author
  */
 public AuthorInformation getAuthorInformation(final Integer authorId) {
   final AuthorInformation authInfo = new AuthorInformation();
   authInfo.setAuthorId(authorId);
   final RESTTagV1 tag = getTagById(authorId);
   if (tag != null
       && ComponentBaseRESTEntityWithPropertiesV1.<RESTTagV1, RESTTagCollectionV1>returnProperty(
               tag, CSConstants.FIRST_NAME_PROPERTY_TAG_ID)
           != null
       && ComponentBaseRESTEntityWithPropertiesV1.returnProperty(
               tag, CSConstants.LAST_NAME_PROPERTY_TAG_ID)
           != null) {
     authInfo.setFirstName(
         ComponentBaseRESTEntityWithPropertiesV1.returnProperty(
                 tag, CSConstants.FIRST_NAME_PROPERTY_TAG_ID)
             .getValue());
     authInfo.setLastName(
         ComponentBaseRESTEntityWithPropertiesV1.returnProperty(
                 tag, CSConstants.LAST_NAME_PROPERTY_TAG_ID)
             .getValue());
     if (ComponentBaseRESTEntityWithPropertiesV1.returnProperty(
             tag, CSConstants.EMAIL_PROPERTY_TAG_ID)
         != null) {
       authInfo.setEmail(
           ComponentBaseRESTEntityWithPropertiesV1.returnProperty(
                   tag, CSConstants.EMAIL_PROPERTY_TAG_ID)
               .getValue());
     }
     if (ComponentBaseRESTEntityWithPropertiesV1.returnProperty(
             tag, CSConstants.ORGANIZATION_PROPERTY_TAG_ID)
         != null) {
       authInfo.setOrganization(
           ComponentBaseRESTEntityWithPropertiesV1.returnProperty(
                   tag, CSConstants.ORGANIZATION_PROPERTY_TAG_ID)
               .getValue());
     }
     if (ComponentBaseRESTEntityWithPropertiesV1.returnProperty(
             tag, CSConstants.ORG_DIVISION_PROPERTY_TAG_ID)
         != null) {
       authInfo.setOrgDivision(
           ComponentBaseRESTEntityWithPropertiesV1.returnProperty(
                   tag, CSConstants.ORG_DIVISION_PROPERTY_TAG_ID)
               .getValue());
     }
     return authInfo;
   }
   return null;
 }
Ejemplo n.º 2
0
  /*
   * Get the Pre Processed Content Specification for a ID and Revision
   */
  public RESTTopicV1 getPreContentSpecById(final Integer id, final Integer revision) {
    final RESTTopicV1 cs = getContentSpecById(id, revision);
    final List<Object[]> specRevisions = getContentSpecRevisionsById(id);

    if (specRevisions == null) return null;

    // Create a sorted set of revision ids that are less the the current
    // revision
    final SortedSet<Integer> sortedSpecRevisions = new TreeSet<Integer>();
    for (final Object[] specRev : specRevisions) {
      if ((Integer) specRev[0] <= cs.getRevision()) {
        sortedSpecRevisions.add((Integer) specRev[0]);
      }
    }

    if (sortedSpecRevisions.size() == 0) return null;

    // Find the Pre Content Spec from the revisions
    RESTTopicV1 preContentSpec = null;
    Integer specRev = sortedSpecRevisions.last();
    while (specRev != null) {
      final RESTTopicV1 contentSpecRev = getContentSpecById(id, specRev);
      if (ComponentBaseRESTEntityWithPropertiesV1
                  .<RESTTopicV1, RESTTopicCollectionV1>returnProperty(
                      contentSpecRev, CSConstants.CSP_TYPE_PROPERTY_TAG_ID)
              != null
          && ComponentBaseRESTEntityWithPropertiesV1.returnProperty(
                  contentSpecRev, CSConstants.CSP_TYPE_PROPERTY_TAG_ID)
              .getValue()
              .equals(CSConstants.CSP_PRE_PROCESSED_STRING)) {
        preContentSpec = contentSpecRev;
        break;
      }
      specRev =
          sortedSpecRevisions.headSet(specRev).isEmpty()
              ? null
              : sortedSpecRevisions.headSet(specRev).last();
    }
    return preContentSpec;
  }