use of com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectType in project midpoint by Evolveum.
the class AbstractPopupTabPanel method initObjectListPanel.
protected Component initObjectListPanel() {
PopupObjectListPanel<O> listPanel = new PopupObjectListPanel<>(ID_OBJECT_LIST_PANEL, getObjectType().getClassDefinition(), true) {
private static final long serialVersionUID = 1L;
@Override
protected List<IColumn<SelectableBean<O>, String>> createDefaultColumns() {
if (AbstractRoleType.class.isAssignableFrom(getType())) {
return new ArrayList<>((Collection) ColumnUtils.getDefaultAbstractRoleColumns(false));
} else {
return super.createDefaultColumns();
}
}
@Override
protected void onUpdateCheckbox(AjaxRequestTarget target, IModel<SelectableBean<O>> rowModel) {
onSelectionPerformed(target, rowModel);
}
@Override
protected List<O> getPreselectedObjectList() {
return getPreselectedObjects();
}
@Override
protected IModel<Boolean> getCheckBoxEnableModel(IModel<SelectableBean<O>> rowModel) {
return getObjectSelectCheckBoxEnableModel(rowModel);
}
@Override
protected ObjectQuery getCustomizeContentQuery() {
ObjectQuery customQuery = AbstractPopupTabPanel.this.addFilterToContentQuery();
if (customQuery == null) {
customQuery = AbstractPopupTabPanel.this.getPageBase().getPrismContext().queryFactory().createQuery();
}
List<ObjectReferenceType> archetypeRefList = getArchetypeRefList();
if (!CollectionUtils.isEmpty(archetypeRefList)) {
List<ObjectFilter> archetypeRefFilterList = new ArrayList<>();
for (ObjectReferenceType archetypeRef : archetypeRefList) {
ObjectFilter filter = AbstractPopupTabPanel.this.getPageBase().getPrismContext().queryFor(AssignmentHolderType.class).item(AssignmentHolderType.F_ARCHETYPE_REF).ref(archetypeRef.getOid()).buildFilter();
((RefFilter) filter).setTargetTypeNullAsAny(true);
archetypeRefFilterList.add(filter);
}
if (!CollectionUtils.isEmpty(archetypeRefFilterList)) {
OrFilter archetypeRefOrFilter = AbstractPopupTabPanel.this.getPageBase().getPrismContext().queryFactory().createOr(archetypeRefFilterList);
customQuery.addFilter(archetypeRefOrFilter);
}
}
ObjectFilter subTypeFilter = getSubtypeFilter();
if (subTypeFilter != null) {
customQuery.addFilter(subTypeFilter);
}
return customQuery;
}
};
listPanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
public boolean isVisible() {
return isObjectListPanelVisible();
}
});
listPanel.setOutputMarkupId(true);
return listPanel;
}
use of com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectType in project midpoint by Evolveum.
the class MultiTypesMemberPopupTabPanel method prepareDelta.
@Override
protected ObjectDelta prepareDelta() {
Class classType = WebComponentUtil.qnameToClass(getPageBase().getPrismContext(), getObjectType().getTypeQName());
ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(getAbstractRoleTypeObject(), getRelationValue());
return getPageBase().getPrismContext().deltaFactory().object().createModificationAddReference(classType, "fakeOid", ObjectType.F_PARENT_ORG_REF, ref.asReferenceValue());
}
use of com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectType in project midpoint by Evolveum.
the class ExpressionValidator method validate.
@Override
public void validate(IValidatable<T> validatable) {
ExpressionType expressionType = expressionTypeModel.getObject();
if (expressionType == null) {
return;
}
PrismContext prismContext = serviceLocator.getPrismContext();
Object valueToValidate = getValueToValidate(validatable);
String contextDesc = " form component expression validation ";
PrismPropertyDefinition<OperationResultType> outputDefinition = prismContext.definitionFactory().createPropertyDefinition(ExpressionConstants.OUTPUT_ELEMENT_NAME, OperationResultType.COMPLEX_TYPE);
Task task = serviceLocator.createSimpleTask(OPERATION_EVALUATE_EXPRESSION);
OperationResult result = new OperationResult(OPERATION_EVALUATE_EXPRESSION);
ExpressionFactory expressionFactory = serviceLocator.getExpressionFactory();
Expression<PrismPropertyValue<OperationResultType>, PrismPropertyDefinition<OperationResultType>> expression;
try {
expression = expressionFactory.makeExpression(expressionType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), contextDesc, task, result);
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException e) {
ValidationError error = new ValidationError();
error.setMessage("Cannot make expression: " + e.getMessage());
validatable.error(error);
return;
}
VariablesMap variables = new VariablesMap();
Class typeClass = (valueToValidate == null ? String.class : valueToValidate.getClass());
variables.put(ExpressionConstants.VAR_INPUT, valueToValidate, typeClass);
variables.putObject(ExpressionConstants.VAR_OBJECT, (ObjectType) getObjectType(), ObjectType.class);
ExpressionEvaluationContext context = new ExpressionEvaluationContext(null, variables, contextDesc, task);
PrismValueDeltaSetTriple<PrismPropertyValue<OperationResultType>> outputTriple;
try {
outputTriple = expression.evaluate(context, result);
} catch (SchemaException | ExpressionEvaluationException | ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException e) {
ValidationError error = new ValidationError();
error.setMessage("Cannot evaluate expression: " + e.getMessage());
validatable.error(error);
return;
}
if (outputTriple == null) {
return;
}
Collection<PrismPropertyValue<OperationResultType>> outputValues = outputTriple.getNonNegativeValues();
if (outputValues.isEmpty()) {
return;
}
if (outputValues.size() > 1) {
ValidationError error = new ValidationError();
error.setMessage("Expression " + contextDesc + " produced more than one value");
validatable.error(error);
}
OperationResultType operationResultType = outputValues.iterator().next().getRealValue();
if (operationResultType == null) {
return;
}
OperationResult returnResult = OperationResult.createOperationResult(operationResultType);
if (!returnResult.isSuccess()) {
ValidationError error = new ValidationError();
if (returnResult.getUserFriendlyMessage() != null) {
error.setMessage(WebModelServiceUtils.translateMessage(returnResult, serviceLocator));
} else {
error.setMessage(returnResult.getMessage());
}
validatable.error(error);
}
}
use of com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectType in project midpoint by Evolveum.
the class PageAuditLogDetails method connectDeltas.
private List<ObjectDeltaOperationType> connectDeltas(List<ObjectDeltaOperationType> deltas) {
Map<PolyStringType, ObjectDeltaOperationType> focusDeltas = new HashMap<>();
List<ObjectDeltaOperationType> otherDeltas = new ArrayList<>();
for (ObjectDeltaOperationType delta : deltas) {
if (delta != null && delta.getObjectDelta() != null && FocusType.class.isAssignableFrom(WebComponentUtil.qnameToClass(getPrismContext(), delta.getObjectDelta().getObjectType()))) {
if (focusDeltas.containsKey(delta.getObjectName())) {
focusDeltas.get(delta.getObjectName()).setResourceName(null);
focusDeltas.get(delta.getObjectName()).setResourceOid(null);
if (delta.getObjectDelta() != null) {
if (focusDeltas.get(delta.getObjectName()).getObjectDelta() == null) {
focusDeltas.get(delta.getObjectName()).setObjectDelta(delta.getObjectDelta());
} else {
focusDeltas.get(delta.getObjectName()).getObjectDelta().getItemDelta().addAll(delta.getObjectDelta().getItemDelta());
}
for (ItemDeltaType itemDelta : delta.getObjectDelta().getItemDelta()) {
if (itemDelta == null) {
// TODO why?
continue;
}
}
}
} else {
focusDeltas.put(delta.getObjectName(), delta);
}
} else {
otherDeltas.add(delta);
}
}
List<ObjectDeltaOperationType> retDeltas = new ArrayList<>();
retDeltas.addAll(focusDeltas.values());
retDeltas.addAll(otherDeltas);
return retDeltas;
}
use of com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectType in project midpoint by Evolveum.
the class ActionsExecutedInformation method mapToJaxb.
private void mapToJaxb(Map<ActionsExecutedObjectsKey, ObjectActionsExecutedEntryType> map, List<ObjectActionsExecutedEntryType> list) {
for (Map.Entry<ActionsExecutedObjectsKey, ObjectActionsExecutedEntryType> entry : map.entrySet()) {
ObjectActionsExecutedEntryType e = entry.getValue().clone();
e.setObjectType(entry.getKey().getObjectType());
e.setOperation(ChangeType.toChangeTypeType(entry.getKey().getOperation()));
e.setChannel(entry.getKey().getChannel());
list.add(e);
}
}
Aggregations