コード例 #1
0
 private ArtefactContainer retrieveContainmentTreeArtifacts(
     final String uuid, final int depth, final boolean isRootTree) {
   final String timerId = "fetching a containment tree";
   Timer.getInstance().start(timerId);
   final Map<String, String> serializedTreeInstances = new HashMap<String, String>();
   final Repository repository =
       RepositoryMediator.getInstance().getComponent(ProtocolType.REPOSITORY_ACCESS);
   final ObjectFactory facto = ObjectFactoryHolder.getInstance();
   final ArtefactContainer artifactContainer = facto.createArtefactContainer();
   final Content uuidRetRequest = facto.createArtefactContainerContent();
   artifactContainer.setContentType(SerializationType.CONTAINMENT_TREE_UUIDS_RETRIEVAL.name());
   uuidRetRequest.setContent(uuid);
   artifactContainer.getContent().add(uuidRetRequest);
   // Send a get request (CONTAINMENT_TREE_UUIDS_RETRIEVAL) to the repository access component
   final ArtefactContainer treeUUIDContainer = repository.get(artifactContainer);
   for (final Content c : treeUUIDContainer.getContent()) {
     c.getContent();
   }
   final List<String> containementTreeUUIDs =
       ContainerTypeMapper.mapContentToStringList(treeUUIDContainer);
   System.err.println(
       "Number containemnt tree members that are part of "
           + uuid
           + ": "
           + containementTreeUUIDs.size());
   // find those instances that are in the object pool and fetch those are not from the repository
   final List<String> uuidsToFetchFromRepository =
       containementTreeUUIDs; // fetchInstancesFromObjectPool(containementTreeUUIDs,
                              // serializedTreeInstances);
   System.err.println("# fetched from the objectpool " + serializedTreeInstances.size());
   final ArtefactContainer requestContainer =
       ObjectFactoryHolder.getInstance().createArtefactContainer();
   if (!uuidsToFetchFromRepository.isEmpty()) {
     requestContainer.setContentType(SerializationType.ARTIFACT_RETRIEVAL.name());
     ContainerTypeMapper.mapToContentList(requestContainer, uuidsToFetchFromRepository);
     final ArtefactContainer responseContainer = repository.get(requestContainer);
     System.err.println("Total # fetched: " + responseContainer.getContent().size());
     final long timeTaken = Timer.getInstance().time(timerId, TimeUnit.MILLISECONDS);
     System.err.println("Time taken to fetch a containment tree (ms): " + timeTaken);
     return responseContainer;
   } else {
     return requestContainer;
   }
 }
コード例 #2
0
  public ArtefactContainer get(final ArtefactContainer artifact)
      throws UnsupportedOperationException {
    final SerializationType type = getArtefactContainerType(artifact.getContentType());
    final ObjectFactory containerFactory = ObjectFactoryHolder.getInstance();
    ArtefactContainer resultsContainer = containerFactory.createArtefactContainer();

    switch (type) {
      case CONTAINMENT_TREE:
        resultsContainer =
            retrieveContainmentTree(
                artifact.getContent().get(0).getContent(),
                Integer.parseInt(artifact.getContent().get(1).getContent()));
        resultsContainer.setContentType(SerializationType.CONTAINMENT_TREE.name());
        break;
      case DEPENDENT_INSTANCES:
        final List<String> dependentUUIDs =
            getAllDependentInstanceUUIDsOf(artifact.getContent().get(0).getContent());
        resultsContainer.setContentType(SerializationType.DEPENDENT_INSTANCES.name());
        for (final String uuid : dependentUUIDs) {
          final Content content = containerFactory.createArtefactContainerContent();
          content.setContent(uuid);
          resultsContainer.getContent().add(content);
        }
        break;
      case SEARCH_ARGUMENTS:
        final List<SearchResultType> searchResults =
            searchInstanceByName(artifact.getContent().get(0).getContent());
        resultsContainer.setContentType(SerializationType.SEARCH_ARGUMENTS.name());
        final Iterator<SearchResultType> itr = searchResults.iterator();
        while (itr.hasNext()) {
          final SearchResultType res = itr.next();
          final SearchResult searchRes =
              ObjectFactoryHolder.getInstance().createArtefactContainerSearchResult();
          searchRes.setContainerIdentity(res.getContainerIdentity());
          searchRes.setInstanceIdentity(res.getInstanceIdentity());
          searchRes.setMetaInstanceIdentity(res.getMetaInstanceIdentity());
          resultsContainer.getSearchResult().add(searchRes);
        }
        break;
      default:
        throw new UnsupportedOperationException("This method is not yet supported");
    }
    return resultsContainer;
  }
コード例 #3
0
 private List<SearchResultType> searchInstanceByName(final String name) {
   final Repository repository =
       RepositoryMediator.getInstance().getComponent(ProtocolType.REPOSITORY_ACCESS);
   final ObjectFactory facto = ObjectFactoryHolder.getInstance();
   final ArtefactContainer artifactContainer = facto.createArtefactContainer();
   final List<SearchResultType> searchResults = new ArrayList<SearchResultType>();
   artifactContainer.setContentType(SerializationType.SEARCH_ARGUMENTS.name());
   final Content searchArgument = facto.createArtefactContainerContent();
   searchArgument.setContent(name);
   artifactContainer.getContent().add(searchArgument);
   final ArtefactContainer reponseContaner = repository.get(artifactContainer);
   for (final SearchResult s : reponseContaner.getSearchResult()) {
     searchResults.add(s);
   }
   return searchResults;
 }
コード例 #4
0
  public void put(final ArtefactContainer artifact) throws UnsupportedOperationException {
    final SerializationType type = getArtefactContainerType(artifact.getContentType());

    switch (type) {
      case CHANGESET_PERSISTENCE:
        persistChangeset();
        break;
      case IN_MEMORY_PERSISTENCE:
        persistInstancesInMemory();
        break;
      case ARTIFACT_PERSISTENCE:
        final List<String> contents = getContentList(artifact.getContent());
        persistArtifacts(contents);
        break;
      case OBJECT_POOL_PERSISTENCE:
        persistObjectPool();
        break;
      default:
        throw new UnsupportedOperationException("This method is not yet supported");
    }
  }