コード例 #1
0
  @Override
  public List<SDataInstance> getDataInstances(
      final long containerId,
      final String containerType,
      final int fromIndex,
      final int numberOfResults)
      throws SDataInstanceException {
    NullCheckingUtil.checkArgsNotNull(containerType);
    final SDataInstanceBuilderFactory fact = BuilderFactory.get(SDataInstanceBuilderFactory.class);
    final Map<String, Object> paraMap =
        CollectionUtil.buildSimpleMap(fact.getContainerIdKey(), containerId);
    paraMap.put(fact.getContainerTypeKey(), containerType);

    try {
      return persistenceRead.selectList(
          new SelectListDescriptor<SDataInstance>(
              "getDataInstancesByContainer",
              paraMap,
              SDataInstance.class,
              SDataInstance.class,
              new QueryOptions(fromIndex, numberOfResults)));
    } catch (final SBonitaReadException e) {
      throw new SDataInstanceException(
          "Unable to check if a data instance already exists for the data container of type "
              + containerType
              + " with id "
              + containerId
              + " for reason: "
              + e.getMessage(),
          e);
    }
  }
コード例 #2
0
  @Override
  public SDataInstance getDataInstance(
      final String dataName, final long containerId, final String containerType)
      throws SDataInstanceException {
    NullCheckingUtil.checkArgsNotNull(dataName, containerType);
    final SDataInstanceBuilderFactory fact = BuilderFactory.get(SDataInstanceBuilderFactory.class);
    final Map<String, Object> paraMap = CollectionUtil.buildSimpleMap(fact.getNameKey(), dataName);
    paraMap.put(fact.getContainerIdKey(), containerId);
    paraMap.put(fact.getContainerTypeKey(), containerType);

    try {
      final SDataInstance dataInstance =
          persistenceRead.selectOne(
              new SelectOneDescriptor<SDataInstance>(
                  "getDataInstancesByNameAndContainer",
                  paraMap,
                  SDataInstance.class,
                  SDataInstance.class)); // conditions :and not or
      if (dataInstance == null) {
        throw new SDataInstanceException("No data instance found");
      }
      return dataInstance;
    } catch (final SBonitaReadException e) {
      throw new SDataInstanceException(
          "Unable to check if a data instance already exists: " + e.getMessage(), e);
    }
  }