class urn_perun_facility_attribute_def_def_reqAups extends FacilityAttributesModuleAbstract implements FacilityAttributesModuleImplApi {

	@Override
	public void checkAttributeSemantics(PerunSessionImpl perunSession, Facility facility, Attribute attribute) throws WrongReferenceAttributeValueException {

		List<String> aups = attribute.valueAsList();

		if (aups == null || aups.isEmpty()) return;

		List<Attribute> allAUPS = perunSession.getPerunBl().getAttributesManagerBl().getEntitylessAttributes(perunSession, availableAups);
		if (allAUPS.isEmpty()) return;

		Set<String> keys = new HashSet<>();

		// fill available keys
		for (Attribute a : allAUPS) {
			if (a != null && a.getValue() != null && a.getValue() instanceof LinkedHashMap) {
				LinkedHashMap<String,String> map = a.valueAsMap();
				keys.addAll(map.keySet());
			}
		}

		for (String aup : aups) {
			if (!keys.contains(aup)) throw new WrongReferenceAttributeValueException(attribute, null, facility, null, aup+" AUP doesn't exist in available organization AUPs.");
		}

	}

}