use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class SceneItemValuePanel method initLayout.
private void initLayout() {
final VisibleEnableBehaviour visibleIfReference = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
SceneItemValue object = getModelObject();
return hasValidReferenceValue(object);
}
};
final VisibleEnableBehaviour visibleIfNotReference = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
SceneItemValue object = getModelObject();
return !hasValidReferenceValue(object);
}
};
final ImagePanel icon = new ImagePanel(ID_ICON, new IconModel(), new TitleModel());
icon.add(visibleIfReference);
add(icon);
final Label label = new Label(ID_LABEL, new LabelModel());
label.add(visibleIfNotReference);
add(label);
final LinkPanel link = new LinkPanel(ID_LINK, new LabelModel()) {
@Override
public void onClick(AjaxRequestTarget target) {
if (!(getModelObject().getSourceValue() instanceof PrismReferenceValue)) {
return;
}
PrismReferenceValue refValue = (PrismReferenceValue) getModelObject().getSourceValue();
ObjectReferenceType ort = new ObjectReferenceType();
ort.setupReferenceValue(refValue);
WebComponentUtil.dispatchToObjectDetailsPage(ort, getPageBase(), false);
}
};
link.add(visibleIfReference);
add(link);
final Label additionalText = new Label(ID_ADDITIONAL_TEXT, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return getModelObject() != null ? getModelObject().getAdditionalText() : null;
}
});
add(additionalText);
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class RepositoryObjectDataProvider method createItem.
private DebugObjectItem createItem(PrismObject<? extends ObjectType> object, OperationResult result) {
DebugObjectItem item = DebugObjectItem.createDebugObjectItem(object);
if (ShadowType.class.isAssignableFrom(object.getCompileTimeClass())) {
PrismReference ref = object.findReference(new ItemPath(ShadowType.F_RESOURCE_REF));
if (ref == null || ref.getValue() == null) {
return item;
}
PrismReferenceValue refValue = ref.getValue();
String resourceOid = refValue.getOid();
ResourceDescription desc = resourceCache.get(resourceOid);
if (desc == null) {
desc = loadDescription(resourceOid, result);
resourceCache.put(resourceOid, desc);
}
item.setResourceName(desc.getName());
item.setResourceType(desc.getType());
}
return item;
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class RepositoryObjectDataProvider method loadDescription.
private ResourceDescription loadDescription(String oid, OperationResult result) {
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(ResourceType.F_CONNECTOR, GetOperationOptions.createResolve());
OperationResult subResult = result.createSubresult(OPERATION_LOAD_RESOURCE);
subResult.addParam("oid", oid);
PrismObject<ResourceType> resource = null;
String type = null;
try {
resource = getModel().getObject(ResourceType.class, oid, options, getPage().createSimpleTask(OPERATION_LOAD_RESOURCE), subResult);
PrismReference ref = resource.findReference(ResourceType.F_CONNECTOR_REF);
if (ref != null && ref.getValue() != null) {
PrismReferenceValue refValue = ref.getValue();
if (refValue.getObject() != null) {
PrismObject connector = refValue.getObject();
PrismProperty<String> pType = connector.findProperty(ConnectorType.F_CONNECTOR_TYPE);
if (pType != null && pType.getRealValue() != null) {
type = pType.getRealValue(String.class);
}
}
}
subResult.recordSuccess();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load resource for account", ex);
subResult.recordFatalError("Couldn't load resource for account.");
} finally {
subResult.recomputeStatus();
}
return new ResourceDescription(oid, WebComponentUtil.getName(resource), type);
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class SearchTest method assignmentResourceRefSearchTest.
@Test
public void assignmentResourceRefSearchTest() throws Exception {
PrismReferenceValue resourceRef = new PrismReferenceValue("10000000-0000-0000-0000-000000000004", ResourceType.COMPLEX_TYPE);
ObjectQuery query = QueryBuilder.queryFor(RoleType.class, prismContext).item(RoleType.F_ASSIGNMENT, AssignmentType.F_CONSTRUCTION, ConstructionType.F_RESOURCE_REF).ref(resourceRef).build();
OperationResult result = new OperationResult("search");
List<PrismObject<RoleType>> roles = repositoryService.searchObjects(RoleType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find one role", 1, roles.size());
assertEquals("Wrong role name", "Judge", roles.get(0).getName().getOrig());
PrismReferenceValue resourceRef2 = new PrismReferenceValue("FFFFFFFF-0000-0000-0000-000000000004", ResourceType.COMPLEX_TYPE);
query = QueryBuilder.queryFor(RoleType.class, prismContext).item(RoleType.F_ASSIGNMENT, AssignmentType.F_CONSTRUCTION, ConstructionType.F_RESOURCE_REF).ref(resourceRef2).build();
roles = repositoryService.searchObjects(RoleType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find zero roles", 0, roles.size());
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class SearchTest method assignmentOrgRefSearchTest.
@Test
public void assignmentOrgRefSearchTest() throws Exception {
PrismReferenceValue o123456 = new PrismReferenceValue("o123456", OrgType.COMPLEX_TYPE);
ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT, AssignmentType.F_ORG_REF).ref(o123456).build();
OperationResult result = new OperationResult("search");
List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find one user", 1, users.size());
assertEquals("Wrong user name", "atestuserX00002", users.get(0).getName().getOrig());
PrismReferenceValue o999 = new PrismReferenceValue("o999", RoleType.COMPLEX_TYPE);
query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT, AssignmentType.F_ORG_REF).ref(o999).build();
users = repositoryService.searchObjects(UserType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find zero users", 0, users.size());
}
Aggregations