use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.
the class ModelImplUtils method getApplicablePolicies.
// from the most to least appropriate
@NotNull
public static <O extends ObjectType> List<ObjectPolicyConfigurationType> getApplicablePolicies(@Nullable Class<O> objectClass, List<String> objectSubtypes, SystemConfigurationType systemConfigurationType) throws ConfigurationException {
List<ObjectPolicyConfigurationType> rv = new ArrayList<>();
List<ObjectPolicyConfigurationType> typeNoSubtype = new ArrayList<>();
List<ObjectPolicyConfigurationType> typeWithSubtype = new ArrayList<>();
List<ObjectPolicyConfigurationType> noTypeNoSubtype = new ArrayList<>();
List<ObjectPolicyConfigurationType> noTypeWithSubtype = new ArrayList<>();
List<ObjectPolicyConfigurationType> all = new ArrayList<>(systemConfigurationType.getDefaultObjectPolicyConfiguration());
for (ObjectPolicyConfigurationType aPolicyConfigurationType : all) {
QName typeQName = aPolicyConfigurationType.getType();
if (typeQName != null) {
ObjectTypes objectType = ObjectTypes.getObjectTypeFromTypeQName(typeQName);
if (objectType == null) {
throw new ConfigurationException("Unknown type " + typeQName + " in default object policy definition or object template definition in system configuration");
}
if (objectType.getClassDefinition() == objectClass) {
String aSubType = aPolicyConfigurationType.getSubtype();
if (aSubType == null) {
typeNoSubtype.add(aPolicyConfigurationType);
} else if (objectSubtypes != null && objectSubtypes.contains(aSubType)) {
typeWithSubtype.add(aPolicyConfigurationType);
}
}
} else {
String aSubType = aPolicyConfigurationType.getSubtype();
if (aSubType == null) {
noTypeNoSubtype.add(aPolicyConfigurationType);
} else if (objectSubtypes != null && objectSubtypes.contains(aSubType)) {
noTypeWithSubtype.add(aPolicyConfigurationType);
}
}
}
rv.addAll(typeWithSubtype);
rv.addAll(typeNoSubtype);
rv.addAll(noTypeWithSubtype);
rv.addAll(noTypeNoSubtype);
return rv;
}
use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.
the class ExpressionHandler method resolveRef.
// Called from the ObjectResolver.resolve
public ObjectType resolveRef(ObjectReferenceType ref, String contextDescription, OperationResult result) throws ObjectNotFoundException, SchemaException {
Class<? extends ObjectType> type;
if (ref.getType() != null) {
ObjectTypes objectTypeType = ObjectTypes.getObjectTypeFromTypeQName(ref.getType());
type = objectTypeType.getClassDefinition();
} else {
type = ObjectType.class;
}
return repositoryService.getObject(type, ref.getOid(), createReadOnlyCollection(), result).asObjectable();
}
use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.
the class ClassMapper method getHQLTypeClass.
public static Class<? extends RObject> getHQLTypeClass(Class<? extends ObjectType> clazz) {
Objects.requireNonNull(clazz, "Class must not be null.");
ObjectTypes type = ObjectTypes.getObjectType(clazz);
Class<? extends RObject> hqlType = TYPES.get(type).getClazz();
if (hqlType == null) {
throw new IllegalStateException("Couldn't find DB type for '" + clazz + "'.");
}
return hqlType;
}
use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.
the class DeleteRepositoryAction method deleteByFilter.
private void deleteByFilter(ObjectTypes type, ObjectQuery query, OperationStatus operation, OperationResult result) throws SchemaException {
ResultHandler<?> handler = (prismObject, operationResult) -> {
try {
State state = options.isAsk() ? askForState(prismObject) : State.DELETE;
switch(state) {
case SKIP:
operation.incrementSkipped();
return true;
case STOP:
return false;
case DELETE:
default:
}
RepositoryService repository = context.getRepository();
repository.deleteObject(prismObject.getCompileTimeClass(), prismObject.getOid(), operationResult);
operation.incrementTotal();
} catch (ObjectNotFoundException ex) {
// object was already gone
} catch (IOException ex) {
context.getLog().error("Couldn't delete object {}, reason: {}", ex, prismObject, ex.getMessage());
operation.incrementError();
}
return true;
};
Collection<SelectorOptions<GetOperationOptions>> opts = new ArrayList<>();
if (options.isRaw()) {
opts.add(new SelectorOptions<>(GetOperationOptions.createRaw()));
}
RepositoryService repository = context.getRepository();
repository.searchObjectsIterative(type.getClassDefinition(), query, handler, opts, true, result);
}
use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.
the class DeleteRepositoryAction method deleteByFilter.
private void deleteByFilter(ObjectQuery query) throws SchemaException {
OperationResult result = new OperationResult(OPERATION_DELETE);
OperationStatus operation = new OperationStatus(context, result);
operation.start();
log.info("Starting delete");
ObjectTypes type = options.getType();
if (type != null) {
deleteByFilter(type, query, operation, result);
} else {
for (ObjectTypes t : ObjectTypes.values()) {
if (Modifier.isAbstract(t.getClassDefinition().getModifiers())) {
continue;
}
deleteByFilter(t, query, operation, result);
}
}
operation.finish();
handleResultOnFinish(operation, "Delete finished");
}
Aggregations