use of com.evolveum.midpoint.prism.path.UniformItemPath in project midpoint by Evolveum.
the class SchemaTransformer method selectItemsToDelete.
@NotNull
private List<ItemName> selectItemsToDelete(PrismContainerDefinition<?> containerDefinition, UniformItemPath containerPath, List<VisibilityPolicyEntry> visibilityPolicy) {
List<ItemName> itemsToDelete = new ArrayList<>();
for (ItemDefinition<?> subDefinition : containerDefinition.getDefinitions()) {
UniformItemPath itemPath = containerPath.append(subDefinition.getItemName());
if (subDefinition instanceof PrismContainerDefinition) {
PrismContainerDefinition<?> subContainerDef = (PrismContainerDefinition<?>) subDefinition;
UserInterfaceElementVisibilityType itemVisibility = reduceItems(subContainerDef, itemPath, visibilityPolicy);
if (subContainerDef.isEmpty()) {
/*
* Empty sub-containers are treated in this way:
* - "completely defined" ones (no xsd:any) are hidden, unless explicitly set
* to VISIBLE i.e. if VACANT, HIDDEN, or AUTOMATIC
* - "open" ones (xsd:any) are dealt with just like properties: hidden if VACANT or HIDDEN
*
* Primary motivation for this behavior is the fact that we need to keep assignment/extension definition
* in the object. It is required for normal model operation, specifically for the construction of "magic
* assignment".
*
* Note that this somehow mixes presentation requirements (hiding/showing items) with the requirements of
* business logic. This is because the current solution is a temporary one, to be replaced by something
* more serious.
*/
if (itemVisibility == VACANT || itemVisibility == HIDDEN || itemVisibility == AUTOMATIC && subContainerDef.isCompletelyDefined()) {
itemsToDelete.add(subDefinition.getItemName());
}
}
} else {
UserInterfaceElementVisibilityType itemVisibility = determineVisibility(visibilityPolicy, itemPath);
if (itemVisibility == VACANT || itemVisibility == HIDDEN) {
itemsToDelete.add(subDefinition.getItemName());
}
}
}
return itemsToDelete;
}
use of com.evolveum.midpoint.prism.path.UniformItemPath in project midpoint by Evolveum.
the class QAccessCertificationCampaignMapping method caseId.
private Long caseId(SelectorOptions<GetOperationOptions> option) {
GetOperationOptions getOp = option.getOptions();
if (getOp == null) {
return null;
}
if (!RetrieveOption.INCLUDE.equals(getOp.getRetrieve())) {
return null;
}
UniformItemPath path = option.getItemPath(null);
if (path == null || path.size() == 1) {
return null;
}
if (!F_CASE.equals(path.firstName())) {
return null;
}
return ItemPath.toIdOrNull(path.getSegment(1));
}
use of com.evolveum.midpoint.prism.path.UniformItemPath in project midpoint by Evolveum.
the class EntityRegistry method init.
@PostConstruct
public void init() {
LOGGER.debug("Starting initialization");
metamodel = sessionFactory.getMetamodel();
for (EntityType<?> entity : metamodel.getEntities()) {
Class<?> javaType = entity.getJavaType();
Ignore ignore = javaType.getAnnotation(Ignore.class);
if (ignore != null) {
continue;
}
Class<?> jaxb;
if (RObject.class.isAssignableFrom(javaType)) {
// noinspection unchecked,rawtypes
jaxb = RObjectType.getType((Class<? extends RObject>) javaType).getJaxbClass();
} else {
JaxbType jaxbType = javaType.getAnnotation(JaxbType.class);
if (jaxbType == null) {
throw new IllegalStateException("Unknown jaxb type for " + javaType.getName());
}
jaxb = jaxbType.type();
}
jaxbMappings.put(jaxb, entity);
// create override map
Map<String, Attribute<?, ?>> overrides = new HashMap<>();
Map<UniformItemPath, Attribute<?, ?>> pathOverrides = new HashMap<>();
for (Attribute<?, ?> attribute : entity.getAttributes()) {
Class<?> jType = attribute.getJavaType();
JaxbPath[] paths = jType.getAnnotationsByType(JaxbPath.class);
if (paths == null || paths.length == 0) {
paths = ((Method) attribute.getJavaMember()).getAnnotationsByType(JaxbPath.class);
}
if (paths == null || paths.length == 0) {
JaxbName name = ((Method) attribute.getJavaMember()).getAnnotation(JaxbName.class);
if (name != null) {
overrides.put(name.localPart(), attribute);
}
continue;
}
for (JaxbPath path : paths) {
JaxbName[] names = path.itemPath();
if (names.length == 1) {
overrides.put(names[0].localPart(), attribute);
} else {
UniformItemPath customPath = prismContext.emptyPath();
for (JaxbName name : path.itemPath()) {
customPath = customPath.append(new QName(name.namespace(), name.localPart()));
}
pathOverrides.put(customPath, attribute);
}
}
}
if (!overrides.isEmpty()) {
attributeNameOverrides.put(entity, overrides);
}
if (!pathOverrides.isEmpty()) {
attributeNamePathOverrides.put(entity, pathOverrides);
}
}
LOGGER.debug("Initialization finished");
}
Aggregations