Ejemplo n.º 1
0
 @Override
 protected AbstractCommonList getCommonList(UriInfo ui) {
   try {
     ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);
     MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
     DocumentHandler handler = createDocumentHandler(ctx);
     String docType = queryParams.getFirst(IQueryManager.SEARCH_TYPE_DOCTYPE);
     String mode = queryParams.getFirst(IQueryManager.SEARCH_TYPE_INVOCATION_MODE);
     String whereClause = null;
     DocumentFilter documentFilter = null;
     String common_part = ctx.getCommonPartLabel();
     if (docType != null && !docType.isEmpty()) {
       whereClause = QueryManager.createWhereClauseForInvocableByDocType(common_part, docType);
       documentFilter = handler.getDocumentFilter();
       documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND);
     }
     if (mode != null && !mode.isEmpty()) {
       whereClause = QueryManager.createWhereClauseForInvocableByMode(common_part, mode);
       documentFilter = handler.getDocumentFilter();
       documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND);
     }
     if (whereClause != null && logger.isDebugEnabled()) {
       logger.debug("The WHERE clause is: " + documentFilter.getWhereClause());
     }
     getRepositoryClient(ctx).getFiltered(ctx, handler);
     AbstractCommonList list = (AbstractCommonList) handler.getCommonPartList();
     return list;
   } catch (Exception e) {
     throw bigReThrow(e, ServiceMessages.LIST_FAILED);
   }
 }
  /**
   * Gets the relation list item, looking up the subject and object documents, and getting summary
   * info via the objectName and objectNumber properties in tenant-bindings.
   *
   * @param ctx the ctx
   * @param sbt the ServiceBindingType of Relations service
   * @param tReader the tenant-bindings reader, for looking up docnumber and docname
   * @param docModel the doc model
   * @param serviceContextPath the service context path
   * @return the relation list item, with nested subject and object summary info.
   * @throws Exception the exception
   */
  private RelationListItem getRelationListItem(
      ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
      ServiceBindingType sbt,
      TenantBindingConfigReaderImpl tReader,
      DocumentModel docModel,
      String serviceContextPath)
      throws Exception {
    RelationListItem relationListItem = new RelationListItem();
    String id = getCsid(docModel);
    relationListItem.setCsid(id);

    relationListItem.setSubjectCsid(
        (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_ID_1));

    String predicate =
        (String)
            docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.RELATIONSHIP_TYPE);
    relationListItem.setRelationshipType(predicate);
    relationListItem.setPredicate(predicate); // predicate is new name for relationshipType.
    relationListItem.setPredicateDisplayName(
        (String)
            docModel.getProperty(
                ctx.getCommonPartLabel(), RelationJAXBSchema.RELATIONSHIP_TYPE_DISPLAYNAME));

    relationListItem.setObjectCsid(
        (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_ID_2));

    relationListItem.setUri(serviceContextPath + id);

    // Now fill in summary info for the related docs: subject and object.
    String subjectCsid = relationListItem.getSubjectCsid();
    String documentType =
        (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_TYPE_1);
    RelationsDocListItem subject =
        createRelationsDocListItem(ctx, sbt, subjectCsid, tReader, documentType);

    // Object o1 =  docModel.getProperty(ctx.getCommonPartLabel(), "subject");
    // Object o2 =  docModel.getProperty(ctx.getCommonPartLabel(), "object");

    String subjectUri =
        (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.subjectUri);
    subject.setUri(subjectUri);
    relationListItem.setSubject(subject);

    String objectCsid = relationListItem.getObjectCsid();
    String documentType2 =
        (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_TYPE_2);
    RelationsDocListItem object =
        createRelationsDocListItem(ctx, sbt, objectCsid, tReader, documentType2);

    String objectUri =
        (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.objectUri);
    object.setUri(objectUri);
    relationListItem.setObject(object);

    return relationListItem;
  }
  protected Object getCommonPart() {
    Object result = null;

    try {
      MultipartServiceContext multiPartCtx = (MultipartServiceContext) getServiceContext();
      result = multiPartCtx.getInputPart(ctx.getCommonPartLabel(), getCommonPartClass());
    } catch (Exception e) {
      if (logger.isDebugEnabled() == true) {
        logger.debug("Could not extract common part from multipart input.", e);
      }
    }

    return result;
  }
 @Override
 public DocumentHandler createDocumentHandler(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx)
     throws Exception {
   return createDocumentHandler(ctx, ctx.getCommonPartLabel(), getCommonPartClass());
 }
 /**
  * Creates the document handler.
  *
  * @param ctx the ctx
  * @param commonClass the common class
  * @return the document handler
  * @throws Exception the exception
  */
 public DocumentHandler createDocumentHandler(
     ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, Class<Object> commonClass) throws Exception {
   return createDocumentHandler(ctx, ctx.getCommonPartLabel(), commonClass);
 }