use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class MidPointSchemaDefinitionFactory method getAnnotationReference.
private ResourceAttributeDefinition getAnnotationReference(XSAnnotation annotation, QName qname, ObjectClassComplexTypeDefinition objectClass) throws SchemaException {
Element element = SchemaProcessorUtil.getAnnotationElement(annotation, qname);
if (element != null) {
String reference = element.getTextContent();
if (reference == null || reference.isEmpty()) {
// Compatibility
reference = element.getAttribute("ref");
}
if (reference != null && !reference.isEmpty()) {
QName referenceItemName = DOMUtil.resolveQName(element, reference);
PrismPropertyDefinition definition = objectClass.findPropertyDefinition(referenceItemName);
if (definition == null) {
throw new SchemaException("The annotation " + qname + " in " + objectClass + " is pointing to " + referenceItemName + " which does not exist");
}
if (definition instanceof ResourceAttributeDefinition) {
return (ResourceAttributeDefinition) definition;
} else {
throw new SchemaException("The annotation " + qname + " in " + objectClass + " is pointing to " + referenceItemName + " which is not an attribute, it is " + definition);
}
}
}
return null;
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class FocusProjectionsTabPanel method createShadowMenu.
private List<InlineMenuItem> createShadowMenu() {
List<InlineMenuItem> items = new ArrayList<InlineMenuItem>();
PrismObjectDefinition def = getObjectWrapper().getObject().getDefinition();
PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
InlineMenuItem item;
if (ref.canRead() && ref.canAdd()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.addShadow"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<QName> supportedTypes = new ArrayList<>(1);
supportedTypes.add(ResourceType.COMPLEX_TYPE);
PageBase pageBase = FocusProjectionsTabPanel.this.getPageBase();
ObjectBrowserPanel<ResourceType> resourceSelectionPanel = new ObjectBrowserPanel<ResourceType>(pageBase.getMainPopupBodyId(), ResourceType.class, supportedTypes, true, pageBase) {
@Override
protected void addPerformed(AjaxRequestTarget target, QName type, List<ResourceType> selected) {
// TODO Auto-generated method stub
FocusProjectionsTabPanel.this.addSelectedAccountPerformed(target, selected);
}
};
resourceSelectionPanel.setOutputMarkupId(true);
pageBase.showMainPopup(resourceSelectionPanel, target);
}
});
items.add(item);
items.add(new InlineMenuItem());
}
PrismPropertyDefinition prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
if (prop.canRead() && prop.canModify()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.enable"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateShadowActivation(target, getSelectedProjections(projectionModel), true);
}
});
items.add(item);
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.disable"), new InlineMenuItemAction() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateShadowActivation(target, getSelectedProjections(projectionModel), false);
}
});
items.add(item);
}
if (ref.canRead() && ref.canAdd()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlink"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
unlinkProjectionPerformed(target, projectionModel, getSelectedProjections(projectionModel), ID_SHADOWS);
}
});
items.add(item);
}
prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS);
if (prop.canRead() && prop.canModify()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlock"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
unlockShadowPerformed(target, projectionModel, getSelectedProjections(projectionModel));
}
});
items.add(item);
}
prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
if (prop.canRead() && prop.canModify()) {
items.add(new InlineMenuItem());
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.delete"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteProjectionPerformed(target, projectionModel);
}
});
items.add(item);
}
return items;
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class AbstractDummyTest method checkConsistency.
protected void checkConsistency(PrismObject<? extends ShadowType> object) throws SchemaException {
OperationResult result = new OperationResult(TestDummyNegative.class.getName() + ".checkConsistency");
PrismPropertyDefinition itemDef = ShadowUtil.getAttributesContainer(object).getDefinition().findAttributeDefinition(SchemaConstants.ICFS_NAME);
LOGGER.info("item definition: {}", itemDef.debugDump());
//TODO: matching rule
ObjectQuery query = QueryBuilder.queryFor(ShadowType.class, prismContext).itemWithDef(itemDef, ShadowType.F_ATTRIBUTES, itemDef.getName()).eq(getWillRepoIcfName()).build();
System.out.println("Looking for shadows of \"" + getWillRepoIcfName() + "\" with filter " + query.debugDump());
display("Looking for shadows of \"" + getWillRepoIcfName() + "\" with filter " + query.debugDump());
List<PrismObject<ShadowType>> objects = repositoryService.searchObjects(ShadowType.class, query, null, result);
assertEquals("Wrong number of repo shadows for ICF NAME \"" + getWillRepoIcfName() + "\"", 1, objects.size());
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class ShadowManager method createSearchShadowQuery.
private ObjectQuery createSearchShadowQuery(ProvisioningContext ctx, PrismObject<ShadowType> resourceShadow, PrismContext prismContext, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(resourceShadow);
PrismProperty identifier = attributesContainer.getPrimaryIdentifier();
Collection<PrismPropertyValue<Object>> idValues = identifier.getValues();
// Only one value is supported for an identifier
if (idValues.size() > 1) {
// TODO: This should probably be switched to checked exception later
throw new IllegalArgumentException("More than one identifier value is not supported");
}
if (idValues.size() < 1) {
// TODO: This should probably be switched to checked exception later
throw new IllegalArgumentException("The identifier has no value");
}
// We have all the data, we can construct the filter now
try {
// TODO TODO TODO TODO: set matching rule instead of null
PrismPropertyDefinition def = identifier.getDefinition();
return QueryBuilder.queryFor(ShadowType.class, prismContext).itemWithDef(def, ShadowType.F_ATTRIBUTES, def.getName()).eq(getNormalizedValue(identifier, ctx.getObjectClassDefinition())).and().item(ShadowType.F_OBJECT_CLASS).eq(resourceShadow.getPropertyRealValue(ShadowType.F_OBJECT_CLASS, QName.class)).and().item(ShadowType.F_RESOURCE_REF).ref(ctx.getResourceOid()).build();
} catch (SchemaException e) {
throw new SchemaException("Schema error while creating search filter: " + e.getMessage(), e);
}
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class AbstractBasicDummyTest method test021Configuration.
@Test
public void test021Configuration() throws Exception {
final String TEST_NAME = "test021Configuration";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME);
// WHEN
resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result);
resourceType = resource.asObjectable();
// THEN
result.computeStatus();
display("getObject result", result);
TestUtil.assertSuccess(result);
// There may be one parse. Previous test have changed the resource version
// Schema for this version will not be re-parsed until getObject is tried
assertResourceSchemaParseCountIncrement(1);
assertResourceCacheMissesIncrement(1);
PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
assertNotNull("No configuration container", configurationContainer);
PrismContainerDefinition confContDef = configurationContainer.getDefinition();
assertNotNull("No configuration container definition", confContDef);
PrismContainer confingurationPropertiesContainer = configurationContainer.findContainer(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME);
assertNotNull("No configuration properties container", confingurationPropertiesContainer);
PrismContainerDefinition confPropsDef = confingurationPropertiesContainer.getDefinition();
assertNotNull("No configuration properties container definition", confPropsDef);
List<PrismProperty<?>> configurationProperties = confingurationPropertiesContainer.getValue().getItems();
assertFalse("No configuration properties", configurationProperties.isEmpty());
for (PrismProperty<?> confProp : configurationProperties) {
PrismPropertyDefinition confPropDef = confProp.getDefinition();
assertNotNull("No definition for configuration property " + confProp, confPropDef);
assertFalse("Configuration property " + confProp + " is raw", confProp.isRaw());
assertConfigurationProperty(confProp);
}
// The useless configuration variables should be reflected to the resource now
assertEquals("Wrong useless string", "Shiver me timbers!", dummyResource.getUselessString());
assertEquals("Wrong guarded useless string", "Dead men tell no tales", dummyResource.getUselessGuardedString());
resource.checkConsistence();
rememberSchemaMetadata(resource);
rememberConnectorInstance(resource);
assertSteadyResource();
}
Aggregations