Search in sources :

Example 81 with PrismContext

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);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) ObjectResolver(com.evolveum.midpoint.schema.util.ObjectResolver) DirectoryFileObjectResolver(com.evolveum.midpoint.test.util.DirectoryFileObjectResolver) DirectoryFileObjectResolver(com.evolveum.midpoint.test.util.DirectoryFileObjectResolver) ArrayList(java.util.ArrayList) FunctionLibrary(com.evolveum.midpoint.model.common.expression.functions.FunctionLibrary) ProtectorImpl(com.evolveum.midpoint.prism.crypto.ProtectorImpl) Protector(com.evolveum.midpoint.prism.crypto.Protector) BeforeClass(org.testng.annotations.BeforeClass)

Example 82 with PrismContext

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);
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) PrismContext(com.evolveum.midpoint.prism.PrismContext) ProtectorImpl(com.evolveum.midpoint.prism.crypto.ProtectorImpl) Protector(com.evolveum.midpoint.prism.crypto.Protector)

Example 83 with PrismContext

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);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext)

Example 84 with PrismContext

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);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition)

Example 85 with PrismContext

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);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) QName(javax.xml.namespace.QName) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) DynamicNamespacePrefixMapper(com.evolveum.midpoint.prism.xml.DynamicNamespacePrefixMapper) Test(org.testng.annotations.Test)

Aggregations

PrismContext (com.evolveum.midpoint.prism.PrismContext)104 Test (org.testng.annotations.Test)59 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)15 QName (javax.xml.namespace.QName)15 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)13 Task (com.evolveum.midpoint.task.api.Task)11 SchemaRegistry (com.evolveum.midpoint.prism.schema.SchemaRegistry)10 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)10 PrismObject (com.evolveum.midpoint.prism.PrismObject)9 SystemException (com.evolveum.midpoint.util.exception.SystemException)9 File (java.io.File)8 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)7 ArrayList (java.util.ArrayList)7 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)6 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)6 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)6 Protector (com.evolveum.midpoint.prism.crypto.Protector)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)5