use of com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition in project midpoint by Evolveum.
the class CapabilityStep method editCapabilityPerformed.
@SuppressWarnings("unchecked")
private void editCapabilityPerformed(final AjaxRequestTarget target, CapabilityDto<? extends CapabilityType> capability) {
dtoModel.getObject().setSelected(capability);
WebMarkupContainer config = getConfigContainer();
WebMarkupContainer newConfig;
CapabilityType capType = capability.getCapability();
if (capType instanceof ActivationCapabilityType) {
newConfig = new CapabilityActivationPanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<ActivationCapabilityType>) capability), parentPage) {
@Override
public IModel<List<QName>> createAttributeChoiceModel(final IChoiceRenderer<QName> renderer) {
LoadableModel<List<QName>> attributeChoiceModel = new LoadableModel<List<QName>>(false) {
@Override
protected List<QName> load() {
List<QName> choices = new ArrayList<>();
PrismObject<ResourceType> resourcePrism = resourceModel.getObject();
try {
ResourceSchema schema = ResourceSchemaFactory.getCompleteSchema(resourcePrism);
if (schema != null) {
// TODO is this OK?
ResourceObjectTypeDefinition def = schema.findDefaultOrAnyObjectTypeDefinition(ShadowKindType.ACCOUNT);
if (def != null) {
for (ResourceAttributeDefinition<?> attribute : def.getAttributeDefinitions()) {
choices.add(attribute.getItemName());
}
}
}
} catch (CommonException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load resource schema attributes.", e);
getPageBase().error("Couldn't load resource schema attributes" + e);
}
choices.sort((o1, o2) -> {
String s1 = (String) renderer.getDisplayValue(o1);
String s2 = (String) renderer.getDisplayValue(o2);
return String.CASE_INSENSITIVE_ORDER.compare(s1, s2);
});
return choices;
}
};
parentPage.registerDependentModel(attributeChoiceModel);
return attributeChoiceModel;
}
};
} else if (capType instanceof ScriptCapabilityType) {
newConfig = new CapabilityScriptPanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<ScriptCapabilityType>) capability), getTable(), parentPage);
} else if (capType instanceof CredentialsCapabilityType) {
newConfig = new CapabilityCredentialsPanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<CredentialsCapabilityType>) capability), getTable(), parentPage);
} else {
newConfig = new CapabilityValuePanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<CapabilityType>) capability), getTable(), parentPage);
}
// TODO other specific capabilities (paged, count, ...)
newConfig.setOutputMarkupId(true);
config.replaceWith(newConfig);
target.add(newConfig);
target.add(getTable());
}
use of com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition in project midpoint by Evolveum.
the class ResourceContentResourcePanel method createAttributeDefinitionList.
private <T extends ObjectType> List<SearchItemDefinition> createAttributeDefinitionList() {
List<SearchItemDefinition> map = new ArrayList<>();
ResourceObjectDefinition ocDef = null;
try {
if (getKind() != null) {
ocDef = getDefinitionByKind();
} else if (getObjectClass() != null) {
ocDef = getDefinitionByObjectClass();
}
} catch (SchemaException e) {
warn("Could not get determine object class definition");
return map;
}
if (ocDef == null) {
return map;
}
for (ResourceAttributeDefinition def : ocDef.getAttributeDefinitions()) {
map.add(new SearchItemDefinition(ItemPath.create(ShadowType.F_ATTRIBUTES, getAttributeName(def)), def, null));
}
return map;
}
use of com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition in project midpoint by Evolveum.
the class TestSanity method checkOpenDjSchema.
private void checkOpenDjSchema(ResourceType resource, String source) throws SchemaException {
ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
ObjectClassComplexTypeDefinition accountDefinition = schema.findObjectClassDefinition(RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
assertNotNull("Schema does not define any account (resource from " + source + ")", accountDefinition);
Collection<? extends ResourceAttributeDefinition> identifiers = accountDefinition.getPrimaryIdentifiers();
assertFalse("No account identifiers (resource from " + source + ")", identifiers == null || identifiers.isEmpty());
// TODO: check for naming attributes and display names, etc
ActivationCapabilityType capActivation = ResourceTypeUtil.getEffectiveCapability(resource, ActivationCapabilityType.class);
if (capActivation != null && capActivation.getStatus() != null && capActivation.getStatus().getAttribute() != null) {
// There is simulated activation capability, check if the attribute is in schema.
QName enableAttrName = capActivation.getStatus().getAttribute();
ResourceAttributeDefinition enableAttrDef = accountDefinition.findAttributeDefinition(enableAttrName);
display("Simulated activation attribute definition", enableAttrDef);
assertNotNull("No definition for enable attribute " + enableAttrName + " in account (resource from " + source + ")", enableAttrDef);
assertTrue("Enable attribute " + enableAttrName + " is not ignored (resource from " + source + ")", enableAttrDef.isIgnored());
}
}
use of com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition in project midpoint by Evolveum.
the class AbstractIntegrationTest method createShadowQuerySecondaryIdentifier.
protected ObjectQuery createShadowQuerySecondaryIdentifier(ObjectClassComplexTypeDefinition rAccount, String identifier, PrismObject<ResourceType> resource) throws SchemaException {
Collection<? extends ResourceAttributeDefinition> identifierDefs = rAccount.getSecondaryIdentifiers();
assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs;
ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next();
//TODO: set matching rule instead of null
return QueryBuilder.queryFor(ShadowType.class, prismContext).itemWithDef(identifierDef, ShadowType.F_ATTRIBUTES, identifierDef.getName()).eq(identifier).and().item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getTypeName()).and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()).build();
}
use of com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition in project midpoint by Evolveum.
the class AbstractIntegrationTest method createAccountShadowQuery.
protected ObjectQuery createAccountShadowQuery(String identifier, PrismObject<ResourceType> resource) throws SchemaException {
RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
Collection<? extends ResourceAttributeDefinition> identifierDefs = rAccount.getPrimaryIdentifiers();
assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs;
ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next();
//TODO: set matching rule instead of null
return QueryBuilder.queryFor(ShadowType.class, prismContext).itemWithDef(identifierDef, ShadowType.F_ATTRIBUTES, identifierDef.getName()).eq(identifier).and().item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()).and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()).build();
}
Aggregations