Skip to content

Commit

Permalink
fixing collection processor to support containerable
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Mar 22, 2022
1 parent 48d5b07 commit c363376
Showing 1 changed file with 31 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,17 @@ public void compileObjectCollectionView(CompiledObjectCollectionView existingVie
}
}

private Class<? extends Containerable> getContainerTypeClass(QName targetTypeQName, ObjectCollectionType objectCollectionType) throws SchemaException {
if (targetTypeQName == null) {
throw new SchemaException("Target container type not specified in " + objectCollectionType);
}
PrismContainerDefinition<Containerable> def = prismContext.getSchemaRegistry().findContainerDefinitionByType(targetTypeQName);
if (def == null) {
throw new IllegalArgumentException("Unsupported container type " + targetTypeQName);
}
return def.getTypeClass();
}

private void compileObjectCollectionView(CompiledObjectCollectionView existingView, CollectionRefSpecificationType baseCollectionSpec,
@NotNull ObjectCollectionType objectCollectionType, Class<? extends Containerable> targetTypeClass, Task task, OperationResult result)
throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException,
Expand All @@ -330,21 +341,23 @@ private void compileObjectCollectionView(CompiledObjectCollectionView existingVi
if (targetTypeClass == null) {
if (existingView.getContainerType() == null) {
QName targetTypeQName = objectCollectionType.getType();
if (targetTypeQName == null) {
throw new SchemaException("Target container type not specified in " + objectCollectionType);
}
targetTypeClass = ObjectTypes.getObjectTypeClassIfKnown(targetTypeQName);
if (targetTypeClass == null) {
PrismContainerDefinition<Containerable> def = prismContext.getSchemaRegistry().findContainerDefinitionByType(targetTypeQName);
if (def == null) {
throw new IllegalArgumentException("Unsupported container type " + targetTypeQName);
}
targetTypeClass = def.getTypeClass();
}

// if (targetTypeQName == null) {
// throw new SchemaException("Target container type not specified in " + objectCollectionType);
// }
// targetTypeClass = ObjectTypes.getObjectTypeClassIfKnown(targetTypeQName);
// if (targetTypeClass == null) {
// PrismContainerDefinition<Containerable> def = prismContext.getSchemaRegistry().findContainerDefinitionByType(targetTypeQName);
// if (def == null) {
// throw new IllegalArgumentException("Unsupported container type " + targetTypeQName);
// }
// targetTypeClass = def.getTypeClass();
// }
targetTypeClass = getContainerTypeClass(targetTypeQName, objectCollectionType);
existingView.setContainerType(targetTypeQName);
} else {
QName targetTypeQName = existingView.getContainerType();
targetTypeClass = ObjectTypes.getObjectTypeClass(targetTypeQName);
targetTypeClass = getContainerTypeClass(targetTypeQName, objectCollectionType);
}
}

Expand Down Expand Up @@ -472,9 +485,13 @@ private void compileCollection(CompiledObjectCollectionView existingView, Collec
ExpressionEvaluationException, ObjectNotFoundException {

QName targetObjectType = existingView.getContainerType();
Class<? extends ObjectType> targetTypeClass = ObjectType.class;
Class<? extends Containerable> targetTypeClass = ObjectType.class;
if (targetObjectType != null) {
targetTypeClass = ObjectTypes.getObjectTypeFromTypeQName(targetObjectType).getClassDefinition();
PrismContainerDefinition<? extends Containerable> containerDefinition = prismContext.getSchemaRegistry().findContainerDefinitionByType(targetObjectType);
if (containerDefinition != null) {
targetTypeClass = containerDefinition.getTypeClass();
}
// targetTypeClass = ObjectTypes.getObjectTypeFromTypeQName(targetObjectType).getClassDefinition();
}
compileObjectCollectionView(existingView, collectionSpec, targetTypeClass, task, result);
}
Expand Down

0 comments on commit c363376

Please sign in to comment.