private void removeFromParents(ResourceType typeToBeRemoved) { // Wrap in new HashSet to avoid ConcurrentModificationExceptions. Set<ResourceType> parentTypes = new HashSet<ResourceType>(typeToBeRemoved.getParentResourceTypes()); for (ResourceType parentType : parentTypes) { parentType.removeChildResourceType(typeToBeRemoved); entityManager.merge(parentType); } }
public Set<ResourceType> getRootTypes() { Set<ResourceType> rootTypes = new HashSet<ResourceType>(); for (ResourceType type : getAllTypes()) { if (type.getParentResourceTypes().size() == 0) { rootTypes.add(type); } } return rootTypes; }
/** * Returns whether or not the given resource type requires a server scan to pick up potential changes. * * @param resourceType type of resource that packages were deployed against * @return <code>true</code> if the resource type refers to a resource that is updated in a server scan; * <code>false</code> otherwise */ private boolean executeServerScan(ResourceType resourceType) { boolean execute = resourceType.getCategory() == ResourceCategory.PLATFORM || (resourceType.getCategory() == ResourceCategory.SERVER && resourceType.getParentResourceTypes().isEmpty()); return execute; } }
for (ResourceType parent : childType.getParentResourceTypes()) { Integer id = parent.getId();
@Override public Map<Integer, ResourceTypeTemplateCountComposite> getTemplateCountCompositeMap() { Query templateCountQuery = entityManager.createNamedQuery(ResourceType.FIND_ALL_TEMPLATE_COUNT_COMPOSITES); @SuppressWarnings("unchecked") List<ResourceTypeTemplateCountComposite> results = templateCountQuery.getResultList(); for (ResourceTypeTemplateCountComposite result : results) { ResourceType type = result.getType(); // TODO (ips, 01/24/11): I tried to fetch the parents via the // ResourceType.FIND_ALL_TEMPLATE_COUNT_COMPOSITES named query, // but was unable to get it working. This will suffice for the time being. type.getParentResourceTypes().size(); } // we don't need to send all the data in resource types over the wire, so we'll be scrubbing the types; // to avoid the scrubbed types getting persisted back to the db, let's clear the persistence context entityManager.clear(); Map<Integer, ResourceTypeTemplateCountComposite> compositeMap = new HashMap<Integer, ResourceTypeTemplateCountComposite>(); for (ResourceTypeTemplateCountComposite result : results) { ResourceType type = result.getType(); // scrub it to avoid sending data over the wire we don't need; // some of these are eagerly loaded, but my paranoia says assume everything is eagerly loaded to purge it all scrubType(type); compositeMap.put(type.getId(), result); } return compositeMap; }
if (existingType != null) { log.debug("Setting parent types on existing type: " + existingType + " to [" + newType.getParentResourceTypes() + "] - current parent types are [" + existingType.getParentResourceTypes() + "]..."); } else { log.debug("Setting parent types on new type: " + newType + " to [" + newType.getParentResourceTypes() + "]..."); Set<ResourceType> newParentTypes = newType.getParentResourceTypes(); newType.setParentResourceTypes(new HashSet<ResourceType>()); Set<ResourceType> originalExistingParentTypes = new HashSet<ResourceType>(); if (existingType != null) { originalExistingParentTypes.addAll(existingType.getParentResourceTypes());
while (toProcess.size() > 0) { ResourceType next = toProcess.pop(); Set<ResourceType> parentTypes = next.getParentResourceTypes(); if (parentTypes != null && parentTypes.size() != 0) { toProcess.addAll(parentTypes);
String plugin = resourceType.getPlugin(); List<String> parents = new ArrayList<String>(); for (ResourceType parent : resourceType.getParentResourceTypes()) { parents.add(parent.getName() + '(' + parent.getPlugin() + ')');
Set<ResourceType> nodeParentTypes = context.getResourceType().getParentResourceTypes(); ResourceType parentType = (ResourceType) nodeParentTypes.toArray()[0]; ResourceType grandParentType = (ResourceType) parentType.getParentResourceTypes().toArray()[0];
Set<ResourceType> nodeParentTypes = context.getResourceType().getParentResourceTypes(); ResourceType parentType = (ResourceType) nodeParentTypes.toArray()[0]; ResourceType grandParentType = (ResourceType) parentType.getParentResourceTypes().toArray()[0];
ResourceType updatedResourceParentType = (updatedParent != null) ? updatedResource.getParentResource() .getResourceType() : null; Set<ResourceType> validParentTypes = existingResource.getResourceType().getParentResourceTypes();
if (!serverType.getParentResourceTypes().isEmpty()) { continue; // TODO GH: Need to stop discovering embedded tomcats here and other non-top level servers
ResourceType parentType = (ResourceType) resourceType.getParentResourceTypes().toArray()[0]; attribute = attributeMap.get(parentType.getName());