예제 #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
 private List<String> getAllDependentInstanceUUIDsOf(final String uuid) {
   final Repository repository =
       RepositoryMediator.getInstance().getComponent(ProtocolType.REPOSITORY_ACCESS);
   final ArtefactContainer artifactContainer =
       ContainerTypeMapper.mapArugmentToArtefactContainerContent(
           uuid, SerializationType.DEPENDENT_INSTANCE_UUIDS);
   final ArtefactContainer resultsContainer = repository.get(artifactContainer);
   final List<String> results = ContainerTypeMapper.mapContentsToStringList(resultsContainer);
   return results;
 }
예제 #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;
 }