use of cz.metacentrum.perun.core.api.ServiceAttributes in project perun by CESNET.
the class ServicesManagerBlImpl method getData.
private ServiceAttributes getData(PerunSession sess, Service service, Facility facility, Resource resource) throws InternalErrorException {
ServiceAttributes resourceServiceAttributes = new ServiceAttributes();
resourceServiceAttributes.addAttributes(getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, resource));
List<Member> members;
members = getPerunBl().getResourcesManagerBl().getAllowedMembers(sess, resource);
HashMap<Member, List<Attribute>> attributes;
try {
attributes = getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, facility, resource, members, true);
} catch (WrongAttributeAssignmentException ex) {
throw new InternalErrorException(ex);
}
for (Member mem : attributes.keySet()) {
ServiceAttributes serviceAttributes = new ServiceAttributes();
serviceAttributes.addAttributes(attributes.get(mem));
resourceServiceAttributes.addChildElement(serviceAttributes);
}
return resourceServiceAttributes;
}
use of cz.metacentrum.perun.core.api.ServiceAttributes in project perun by CESNET.
the class ServicesManagerBlImpl method getFlatData.
public ServiceAttributes getFlatData(PerunSession sess, Service service, Facility facility) throws InternalErrorException {
ServiceAttributes serviceAttributes = new ServiceAttributes();
serviceAttributes.addAttributes(getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, facility));
ServiceAttributes allResourcesServiceAttributes = new ServiceAttributes();
List<Resource> facilityResources = getPerunBl().getFacilitiesManagerBl().getAssignedResources(sess, facility);
facilityResources.retainAll(getAssignedResources(sess, service));
for (Resource resource : facilityResources) {
ServiceAttributes resourceServiceAttributes = new ServiceAttributes();
resourceServiceAttributes.addAttributes(getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, resource));
allResourcesServiceAttributes.addChildElement(resourceServiceAttributes);
}
ServiceAttributes allUsersServiceAttributes = new ServiceAttributes();
List<User> facilityUsers = getPerunBl().getFacilitiesManagerBl().getAllowedUsers(sess, facility, null, service);
// get attributes for all users at once !
HashMap<User, List<Attribute>> userFacilityAttributes = getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, facility, facilityUsers);
HashMap<User, List<Attribute>> userAttributes = getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, facilityUsers);
for (User user : facilityUsers) {
ServiceAttributes userServiceAttributes = new ServiceAttributes();
// Depending on a service requirements we might get null user or user-facility attributes
if (userAttributes.get(user) != null)
userServiceAttributes.addAttributes(userAttributes.get(user));
if (userFacilityAttributes.get(user) != null)
userServiceAttributes.addAttributes(userFacilityAttributes.get(user));
allUsersServiceAttributes.addChildElement(userServiceAttributes);
}
serviceAttributes.addChildElement(allResourcesServiceAttributes);
serviceAttributes.addChildElement(allUsersServiceAttributes);
return serviceAttributes;
}
use of cz.metacentrum.perun.core.api.ServiceAttributes in project perun by CESNET.
the class ServicesManagerBlImpl method getHierarchicalData.
public ServiceAttributes getHierarchicalData(PerunSession sess, Service service, Facility facility) throws InternalErrorException {
ServiceAttributes serviceAttributes = new ServiceAttributes();
serviceAttributes.addAttributes(getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, facility));
List<Resource> resources = getPerunBl().getFacilitiesManagerBl().getAssignedResources(sess, facility);
resources.retainAll(getAssignedResources(sess, service));
for (Resource resource : resources) {
ServiceAttributes resourceServiceAttributes = getData(sess, service, facility, resource);
serviceAttributes.addChildElement(resourceServiceAttributes);
}
return serviceAttributes;
}
use of cz.metacentrum.perun.core.api.ServiceAttributes in project perun by CESNET.
the class ServicesManagerBlImpl method getDataWithGroups.
private ServiceAttributes getDataWithGroups(PerunSession sess, Service service, Facility facility, Resource resource) throws InternalErrorException {
ServiceAttributes resourceServiceAttributes = new ServiceAttributes();
resourceServiceAttributes.addAttributes(getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, resource));
//Add there also voRequiredAttributes for service
try {
Vo resourceVo = getPerunBl().getVosManagerBl().getVoById(sess, resource.getVoId());
resourceServiceAttributes.addAttributes(getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, resourceVo));
} catch (VoNotExistsException ex) {
throw new ConsistencyErrorException("There is missing Vo for existing resource " + resource);
}
ServiceAttributes membersAbstractSA = new ServiceAttributes();
Map<Member, ServiceAttributes> memberAttributes = new HashMap<Member, ServiceAttributes>();
List<Member> members = getPerunBl().getResourcesManagerBl().getAllowedMembers(sess, resource);
HashMap<Member, List<Attribute>> attributes;
try {
attributes = getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, facility, resource, members, true);
} catch (WrongAttributeAssignmentException ex) {
throw new InternalErrorException(ex);
}
for (Member mem : attributes.keySet()) {
ServiceAttributes tmpAttributes = new ServiceAttributes();
tmpAttributes.addAttributes(attributes.get(mem));
memberAttributes.put(mem, tmpAttributes);
membersAbstractSA.addChildElement(tmpAttributes);
}
ServiceAttributes groupsAbstractSA = new ServiceAttributes();
List<Group> groups = getPerunBl().getResourcesManagerBl().getAssignedGroups(sess, resource);
for (Group group : groups) {
groupsAbstractSA.addChildElement(getData(sess, service, facility, resource, group, memberAttributes));
}
//assign abstract services attributes to resource service attributes
resourceServiceAttributes.addChildElement(groupsAbstractSA);
resourceServiceAttributes.addChildElement(membersAbstractSA);
return resourceServiceAttributes;
}
use of cz.metacentrum.perun.core.api.ServiceAttributes in project perun by CESNET.
the class ServicesManagerBlImpl method getData.
private ServiceAttributes getData(PerunSession sess, Service service, Resource resource) throws InternalErrorException {
ServiceAttributes resourceServiceAttributes = new ServiceAttributes();
resourceServiceAttributes.addAttributes(getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, resource));
List<Member> members;
members = getPerunBl().getResourcesManagerBl().getAllowedMembers(sess, resource);
HashMap<Member, List<Attribute>> attributes;
try {
attributes = getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, null, resource, members, true);
} catch (WrongAttributeAssignmentException ex) {
throw new InternalErrorException(ex);
}
for (Member mem : attributes.keySet()) {
ServiceAttributes serviceAttributes = new ServiceAttributes();
serviceAttributes.addAttributes(attributes.get(mem));
resourceServiceAttributes.addChildElement(serviceAttributes);
}
return resourceServiceAttributes;
}
Aggregations