public void setResourceTypeInNewTx(int resourceGroupId) throws ResourceGroupDeleteException {
Query query = entityManager.createNamedQuery(ResourceType.QUERY_GET_EXPLICIT_RESOURCE_TYPE_COUNTS_BY_GROUP);
query.setParameter("groupId", resourceGroupId);
Subject overlord = subjectManager.getOverlord();
ResourceGroup resourceGroup = getResourceGroupById(overlord, resourceGroupId, null);
@SuppressWarnings("unchecked")
List<Object> results = query.getResultList();
if (results.size() == 1) {
Object[] info = (Object[]) results.get(0);
int resourceTypeId = (Integer) info[0];
ResourceType flyWeightType = new ResourceType();
flyWeightType.setId(resourceTypeId);
resourceGroup.setResourceType(flyWeightType);
} else {
if (resourceGroup.getResourceType() != null) {
// converting compatible group to mixed group, remove all corresponding compatible constructs
removeCompatibleGroupConstructs(overlord, resourceGroup);
}
resourceGroup.setResourceType(null);
}
}