use of com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition in project midpoint by Evolveum.
the class FocusProjectionsTabPanel method addSelectedAccountPerformed.
private void addSelectedAccountPerformed(AjaxRequestTarget target, List<ResourceType> newResources) {
getPageBase().hideMainPopup(target);
if (newResources.isEmpty()) {
warn(getString("pageUser.message.noResourceSelected"));
return;
}
for (ResourceType resource : newResources) {
try {
ShadowType shadow = new ShadowType();
ObjectReferenceType resourceRef = new ObjectReferenceType();
resourceRef.asReferenceValue().setObject(resource.asPrismObject());
shadow.setResourceRef(resourceRef);
ResourceType usedResource = resource;
ResourceSchema refinedSchema = ResourceSchemaFactory.getCompleteSchema(resource.asPrismObject(), LayerType.PRESENTATION);
if (refinedSchema == null) {
Task task = getPageBase().createSimpleTask(FocusPersonasTabPanel.class.getSimpleName() + ".loadResource");
OperationResult result = task.getResult();
PrismObject<ResourceType> loadedResource = WebModelServiceUtils.loadObject(ResourceType.class, resource.getOid(), getPageBase(), task, result);
result.recomputeStatus();
refinedSchema = ResourceSchemaFactory.getCompleteSchema(loadedResource, LayerType.PRESENTATION);
if (refinedSchema == null) {
error(getString("pageAdminFocus.message.couldntCreateAccountNoSchema", resource.getName()));
continue;
}
// shadow.setResource(loadedResource.asObjectable());
usedResource = loadedResource.asObjectable();
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Refined schema for {}\n{}", resource, refinedSchema.debugDump());
}
ResourceObjectTypeDefinition accountDefinition = refinedSchema.findDefaultOrAnyObjectTypeDefinition(ShadowKindType.ACCOUNT);
if (accountDefinition == null) {
error(getString("pageAdminFocus.message.couldntCreateAccountNoAccountSchema", resource.getName()));
continue;
}
// shadow.asPrismContainer().findOrCreateContainer(ShadowType.F_ATTRIBUTES).applyDefinition(accountDefinition.toResourceAttributeContainerDefinition());
QName objectClass = accountDefinition.getObjectClassDefinition().getTypeName();
ObjectReferenceType usedResourceRef = new ObjectReferenceType();
usedResourceRef.asReferenceValue().setObject(usedResource.asPrismObject());
shadow.setResourceRef(usedResourceRef);
shadow.setObjectClass(objectClass);
shadow.setIntent(accountDefinition.getIntent());
shadow.setKind(accountDefinition.getKind());
getPrismContext().adopt(shadow);
Task task = getPageBase().createSimpleTask(OPERATION_ADD_ACCOUNT);
PrismObjectWrapperFactory<ShadowType> factory = getPageBase().getRegistry().getObjectWrapperFactory(shadow.asPrismContainer().getDefinition());
WrapperContext context = new WrapperContext(task, task.getResult());
ShadowWrapper wrapperNew = (ShadowWrapper) factory.createObjectWrapper(shadow.asPrismContainer(), ItemStatus.ADDED, context);
if (task.getResult() != null && !WebComponentUtil.isSuccessOrHandledError(task.getResult())) {
showResult(task.getResult(), false);
}
wrapperNew.setProjectionStatus(UserDtoStatus.ADD);
projectionModel.getObject().add(wrapperNew);
} catch (Exception ex) {
error(getString("pageAdminFocus.message.couldntCreateAccount", resource.getName(), ex.getMessage()));
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create account", ex);
}
}
target.add(getMultivalueContainerListPanel());
}
use of com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition in project midpoint by Evolveum.
the class SynchronizationContext method getIntent.
public String getIntent() throws SchemaException {
if (!hasApplicablePolicy()) {
return SchemaConstants.INTENT_UNKNOWN;
}
if (intent == null) {
ResourceSchema schema = ResourceSchemaFactory.getCompleteSchema(resource);
ResourceObjectDefinition def = schema.findObjectDefinition(getKind(), null);
if (def instanceof ResourceObjectTypeDefinition) {
// TODO ???
intent = ((ResourceObjectTypeDefinition) def).getIntent();
}
}
return intent;
}
use of com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition in project midpoint by Evolveum.
the class SynchronizationContext method findObjectTypeDefinition.
ResourceObjectTypeDefinition findObjectTypeDefinition() throws SchemaException {
ResourceSchema refinedResourceSchema = ResourceSchemaFactory.getCompleteSchema(resource);
ShadowKindType kind = getKind();
// FIXME this hacking
String intent = getIntent();
if (kind == null || kind == ShadowKindType.UNKNOWN) {
// nothing to look for
return null;
}
if (SchemaConstants.INTENT_UNKNOWN.equals(intent)) {
intent = null;
}
// FIXME the cast
return (ResourceObjectTypeDefinition) refinedResourceSchema.findObjectDefinition(kind, intent);
}
use of com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition in project midpoint by Evolveum.
the class SynchronizationServiceImpl method processTag.
private <F extends FocusType> void processTag(SynchronizationContext<F> syncCtx, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException {
PrismObject<ShadowType> applicableShadow = syncCtx.getShadowedResourceObject();
if (applicableShadow.asObjectable().getTag() != null) {
return;
}
ResourceObjectTypeDefinition rOcd = syncCtx.findObjectTypeDefinition();
if (rOcd == null) {
// We probably do not have kind/intent yet.
return;
}
ResourceObjectMultiplicityType multiplicity = rOcd.getObjectMultiplicity();
if (!RefinedDefinitionUtil.isMultiaccount(multiplicity)) {
return;
}
String tag = synchronizationExpressionsEvaluator.generateTag(multiplicity, applicableShadow, syncCtx.getResource(), syncCtx.getSystemConfiguration(), "tag expression for " + applicableShadow, syncCtx.getTask(), result);
LOGGER.debug("SYNCHRONIZATION: TAG generated: {}", tag);
syncCtx.setTag(tag);
}
use of com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition in project midpoint by Evolveum.
the class TestDummyExtra method assertSchemaSanity.
@Override
protected void assertSchemaSanity(ResourceSchema resourceSchema, ResourceType resourceType) throws Exception {
// schema is extended, displayOrders are changed
dummyResourceCtl.assertDummyResourceSchemaSanityExtended(resourceSchema, resourceType, false, 20);
ResourceSchema refinedSchema = ResourceSchemaFactory.getCompleteSchema(resource);
ResourceObjectTypeDefinition accountRDef = refinedSchema.findDefaultOrAnyObjectTypeDefinition(ShadowKindType.ACCOUNT);
Collection<ResourceAssociationDefinition> associationDefinitions = accountRDef.getAssociationDefinitions();
assertEquals("Wrong number of association defs", 3, associationDefinitions.size());
ResourceAssociationDefinition crewAssociationDef = accountRDef.findAssociationDefinition(ASSOCIATION_CREW_NAME);
assertNotNull("No definition for crew association", crewAssociationDef);
}
Aggregations