コード例 #1
0
  public void load(EdlDocument edlDocument, String packageName)
      throws ClassNotFoundException, KnowledgeContainerException {
    components = new HashMap<String, BaseDataContract[]>();

    for (DataContractDefinition contract : edlDocument.getDataContracts()) {
      @SuppressWarnings("unchecked")
      Class<? extends BaseDataContract> roleClass =
          (Class<? extends BaseDataContract>) Class.forName(packageName + "." + contract.getName());
      Collection<? extends BaseDataContract> instancesUnsorted =
          knowledgeContainer.getTrackedKnowledgeForRole(roleClass);

      BaseDataContract[] instances = new BaseDataContract[instancesUnsorted.size()];
      String dataContractName = contract.getName();

      //			for (int i = 0; !instancesUnsorted.isEmpty(); i++) {
      //				BaseDataContract minInstance = instancesUnsorted.iterator().next();
      //				for (BaseDataContract instance : instancesUnsorted) {
      ////					if (Integer.parseInt(instance.id) < Integer.parseInt(minInstance.id)) {
      ////						minInstance = instance;
      ////					}
      //
      //					if (instance.id.compareTo(minInstance.id) < 0) {
      //						minInstance = instance;
      //					}
      //				}
      //
      //				instances[i] = minInstance;
      //				instancesUnsorted.remove(minInstance);
      //			}

      // TODO Fairly confident that the sorted property was not used anywhere - keep in mind if
      // anything blows up though
      components.put(dataContractName, instancesUnsorted.toArray(new BaseDataContract[0]));
    }
  }
コード例 #2
0
  /*
  public int[] getGlobalIndices(List<? extends BaseDataContract> instances) {
  	int[] result = new int[instances.size()];

  	for (int i = 0; i < instances.size(); i++) {
  		result[i] = Integer.parseInt(instances.get(i).id);
  		usedComponentIds.add(result[i]);
  	}

  	return result;
  }

  public Set<Integer> getUsedComponentIds() {
  	return usedComponentIds;
  }
  */
  public <TDataContract> int getMaxEnsembleCount(
      EdlDocument edlDocument, EnsembleDefinition ensembleDefinition) {
    int result = Integer.MAX_VALUE;

    // TODO Extend to int ranges
    if (Extensions.hasDataContractBoundId(ensembleDefinition)) {
      QualifiedName idType = ensembleDefinition.getId().getType();
      result = components.get(idType.getName()).length;
    } else {
      for (DataContractDefinition contract : edlDocument.getDataContracts()) {
        int maxEnsembleCount = getMaxEnsembleCount(contract.getName(), ensembleDefinition);
        if (maxEnsembleCount < result) {
          result = maxEnsembleCount;
        }
      }
    }

    return result;
  }