コード例 #1
0
  public RecordLinkWeb updateRecordLink(EntityWeb entityModel, RecordLinkWeb linkPair)
      throws Exception {
    log.debug("Received request to updaty an entity record link.");

    authenticateCaller();
    try {
      RecordQueryService entityInstanceService = Context.getRecordQueryService();
      RecordManagerService entityInstanceManagerService = Context.getRecordManagerService();
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());

      RecordLink recordLink = ModelTransformer.mapToRecordLink(linkPair, RecordLink.class);

      RecordLink record =
          entityInstanceService.loadRecordLink(entityDef, recordLink.getRecordLinkId());
      record.setState(recordLink.getState());
      record = entityInstanceManagerService.updateRecordLink(record);

      RecordLinkWeb recordWeb = ModelTransformer.mapToRecordLink(record, RecordLinkWeb.class, true);

      return recordWeb;
    } catch (Throwable t) {
      log.error("Failed to execute: " + t.getMessage(), t);
      throw new RuntimeException(t);
    }
  }
コード例 #2
0
  public RecordLinkWeb loadRecordLinks(
      EntityWeb entityModel, Long leftRecordId, Long rightRecordId, String state) throws Exception {
    log.debug("Received request to retrieve a list of entity record links.");

    authenticateCaller();
    try {
      RecordQueryService entityInstanceService = Context.getRecordQueryService();
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());

      List<RecordLink> records =
          entityInstanceService.loadRecordLinks(
              entityDef, rightRecordId, RecordLinkState.fromString(state));

      for (RecordLink record : records) {

        // loadRecordLinks with left and right Records
        RecordLink recordlLink =
            entityInstanceService.loadRecordLink(entityDef, record.getRecordLinkId());
        if (recordlLink.getLeftRecord().getRecordId() == leftRecordId
            || recordlLink.getRightRecord().getRecordId() == leftRecordId) {

          RecordLinkWeb recordlLinkWeb =
              ModelTransformer.mapToRecordLink(recordlLink, RecordLinkWeb.class, true);
          return recordlLinkWeb;
        }
      }
      return null;
    } catch (Throwable t) {
      log.error("Failed to execute: " + t.getMessage(), t);
      throw new RuntimeException(t);
    }
  }
コード例 #3
0
  public List<RecordLinkWeb> loadRecordLinks(
      EntityWeb entityModel, String state, int firstResult, int maxResults) throws Exception {
    log.debug("Received request to retrieve a list of entity record links.");

    authenticateCaller();
    try {
      RecordQueryService entityInstanceService = Context.getRecordQueryService();
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());

      List<RecordLink> records =
          entityInstanceService.loadRecordLinks(
              entityDef, RecordLinkState.fromString(state), firstResult, maxResults);

      List<RecordLinkWeb> dtos = new java.util.ArrayList<RecordLinkWeb>(records.size());
      for (RecordLink record : records) {

        // loadRecordLinks without left and right Records
        RecordLinkWeb dto = ModelTransformer.mapToRecordLink(record, RecordLinkWeb.class, false);
        dtos.add(dto);
      }

      return dtos;
    } catch (Throwable t) {
      log.error("Failed to execute: " + t.getMessage(), t);
      throw new RuntimeException(t);
    }
  }
コード例 #4
0
  @Override
  public RecordLinksListWeb loadRecordLinksPaged(RecordSearchCriteriaWeb searchCriteria)
      throws Exception {
    log.debug("Get Record Links");

    authenticateCaller();
    try {
      RecordQueryService entityInstanceService = Context.getRecordQueryService();
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();

      EntityWeb entityModel = searchCriteria.getEntityModel();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());

      int offset = searchCriteria.getFirstResult();
      int pageSize = searchCriteria.getMaxResults();
      String state = searchCriteria.getSearchMode().substring(0, 1);

      // Get total count
      Long totalCount = searchCriteria.getTotalCount();
      if (totalCount == 0) {
        totalCount =
            entityInstanceService.getRecordLinkCount(entityDef, RecordLinkState.fromString(state));
      }

      // get List of Record
      List<RecordLink> recordLinks =
          entityInstanceService.loadRecordLinks(
              entityDef, RecordLinkState.fromString(state), offset, pageSize);

      List<RecordLinkWeb> dtos = new java.util.ArrayList<RecordLinkWeb>(recordLinks.size());
      for (RecordLink record : recordLinks) {

        // loadRecordLinks without left and right Records
        RecordLinkWeb dto = ModelTransformer.mapToRecordLink(record, RecordLinkWeb.class, false);
        dtos.add(dto);
      }

      RecordLinksListWeb recordList = new RecordLinksListWeb();
      recordList.setTotalCount(totalCount);
      recordList.setRecordLinks(dtos);

      return recordList;

    } catch (Exception e) {
      log.error("Failed while trying to get audit events: " + e, e);
    }
    return null;
  }