use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class AbstractScriptTest method setupFactory.
@BeforeClass
public void setupFactory() {
PrismContext prismContext = PrismTestUtil.getPrismContext();
ObjectResolver resolver = new DirectoryFileObjectResolver(OBJECTS_DIR);
Protector protector = new ProtectorImpl();
Collection<FunctionLibrary> functions = new ArrayList<FunctionLibrary>();
functions.add(FunctionLibraryUtil.createBasicFunctionLibrary(prismContext, protector));
scriptExpressionfactory = new ScriptExpressionFactory(resolver, prismContext, protector);
scriptExpressionfactory.setFunctions(functions);
evaluator = createEvaluator(prismContext, protector);
String languageUrl = evaluator.getLanguageUrl();
System.out.println("Expression test for " + evaluator.getLanguageName() + ": registering " + evaluator + " with URL " + languageUrl);
scriptExpressionfactory.registerEvaluator(languageUrl, evaluator);
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class TestExpressionFunctions method createBasicFunctions.
private BasicExpressionFunctions createBasicFunctions() throws SchemaException, SAXException, IOException {
PrismContext prismContext = PrismTestUtil.createInitializedPrismContext();
Protector protector = new ProtectorImpl();
return new BasicExpressionFunctions(prismContext, protector);
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class AddFocusAction method handle.
/* (non-Javadoc)
* @see com.evolveum.midpoint.model.sync.Action#handle(com.evolveum.midpoint.model.lens.LensContext, com.evolveum.midpoint.model.sync.SynchronizationSituation, java.util.Map, com.evolveum.midpoint.task.api.Task, com.evolveum.midpoint.schema.result.OperationResult)
*/
@Override
public <F extends FocusType> void handle(LensContext<F> context, SynchronizationSituation<F> situation, Map<QName, Object> parameters, Task task, OperationResult parentResult) throws SchemaException {
if (context == null) {
throw new UnsupportedOperationException("addFocus action is not supported with synchronize=false");
}
PrismContext prismContext = context.getPrismContext();
LensFocusContext<F> focusContext = context.createFocusContext();
Class<F> focusClass = focusContext.getObjectTypeClass();
LOGGER.trace("addFocus action: add delta for {}", focusClass);
PrismObjectDefinition<F> focusDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(focusClass);
PrismObject<F> emptyFocus = focusDefinition.instantiate();
ObjectDelta<F> delta = emptyFocus.createAddDelta();
delta.setObjectToAdd(emptyFocus);
focusContext.setPrimaryDelta(delta);
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class ModelEvent method hasFocusOfType.
public boolean hasFocusOfType(QName focusType) {
PrismContext prismContext = getModelContext().getPrismContext();
if (prismContext == null) {
throw new IllegalStateException("No prismContext in model context");
}
PrismContainerDefinition pcd = prismContext.getSchemaRegistry().findContainerDefinitionByType(focusType);
if (pcd == null) {
LOGGER.warn("Couldn't find definition for type " + focusType);
return false;
}
Class expectedClass = pcd.getCompileTimeClass();
if (expectedClass == null) {
LOGGER.warn("Couldn't find class for type " + focusType);
return false;
}
return hasFocusOfType(expectedClass);
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class TestSchemaSanity method testPrefixMappings.
@Test
public void testPrefixMappings() {
System.out.println("===[ testPrefixMappings ]===");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
assertNotNull("No prism context", prismContext);
SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
assertNotNull("No schema registry in context", schemaRegistry);
DynamicNamespacePrefixMapper prefixMapper = schemaRegistry.getNamespacePrefixMapper();
assertNotNull("No prefix mapper in context", prefixMapper);
System.out.println("Prefix mapper:");
System.out.println(prefixMapper.debugDump());
// WHEN, THEN
assertMapping(prefixMapper, PrismConstants.NS_ANNOTATION, PrismConstants.PREFIX_NS_ANNOTATION);
assertMapping(prefixMapper, SchemaConstantsGenerated.NS_COMMON, "");
assertMapping(prefixMapper, MidPointConstants.NS_RA, MidPointConstants.PREFIX_NS_RA);
assertMapping(prefixMapper, SchemaTestConstants.NS_ICFC, "icfc");
assertMapping(prefixMapper, SchemaTestConstants.NS_ICFS, "icfs");
QName cBarQName = new QName(SchemaConstantsGenerated.NS_COMMON, "bar");
QName cBarQNameWithPrefix = prefixMapper.setQNamePrefix(cBarQName);
assertQName("common namespace implicit", SchemaConstantsGenerated.NS_COMMON, "bar", "", cBarQNameWithPrefix);
QName cBarQNameWithPrefixExplixit = prefixMapper.setQNamePrefixExplicit(cBarQName);
assertQName("common namespace implicit", SchemaConstantsGenerated.NS_COMMON, "bar", "c", cBarQNameWithPrefixExplixit);
}
Aggregations