use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class ScenePanel method initLayout.
private void initLayout() {
final IModel<SceneDto> model = getModel();
WebMarkupContainer box = new WebMarkupContainer(ID_BOX);
box.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
SceneDto dto = model.getObject();
if (dto.getBoxClassOverride() != null) {
return dto.getBoxClassOverride();
}
if (dto.getChangeType() == null) {
return null;
}
switch(dto.getChangeType()) {
case ADD:
return "box-success";
case DELETE:
return "box-danger";
case MODIFY:
return "box-info";
default:
return null;
}
}
}));
add(box);
WebMarkupContainer headerPanel = new WebMarkupContainer(ID_HEADER_PANEL);
box.add(headerPanel);
headerPanel.add(new SceneButtonPanel(ID_OPTION_BUTTONS, model) {
@Override
public void minimizeOnClick(AjaxRequestTarget target) {
headerOnClickPerformed(target, model);
}
});
Label headerChangeType = new Label(ID_HEADER_CHANGE_TYPE, new ChangeTypeModel());
//headerChangeType.setRenderBodyOnly(true);
Label headerObjectType = new Label(ID_HEADER_OBJECT_TYPE, new ObjectTypeModel());
//headerObjectType.setRenderBodyOnly(true);
IModel<String> nameModel = new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return model.getObject().getName(ScenePanel.this);
}
};
Label headerNameLabel = new Label(ID_HEADER_NAME_LABEL, nameModel);
LinkPanel headerNameLink = new LinkPanel(ID_HEADER_NAME_LINK, nameModel) {
@Override
public void onClick(AjaxRequestTarget target) {
PrismContainerValue<?> value = getModelObject().getScene().getSourceValue();
if (value != null && value.getParent() instanceof PrismObject) {
PrismObject<? extends ObjectType> object = (PrismObject<? extends ObjectType>) value.getParent();
WebComponentUtil.dispatchToObjectDetailsPage(ObjectTypeUtil.createObjectRef(object), getPageBase(), false);
}
}
};
Label headerDescription = new Label(ID_HEADER_DESCRIPTION, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return model.getObject().getDescription(ScenePanel.this);
}
});
Label headerWrapperDisplayName = new Label(ID_HEADER_WRAPPER_DISPLAY_NAME, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
String key = ((WrapperScene) getModelObject().getScene()).getDisplayNameKey();
Object[] parameters = ((WrapperScene) getModelObject().getScene()).getDisplayNameParameters();
return new StringResourceModel(key, this).setModel(null).setDefaultValue(key).setParameters(parameters).getObject();
}
});
headerPanel.add(headerChangeType);
headerPanel.add(headerObjectType);
headerPanel.add(headerNameLabel);
headerPanel.add(headerNameLink);
headerPanel.add(headerDescription);
headerPanel.add(headerWrapperDisplayName);
headerChangeType.add(createHeaderOnClickBehaviour(model));
headerObjectType.add(createHeaderOnClickBehaviour(model));
headerNameLabel.add(createHeaderOnClickBehaviour(model));
headerDescription.add(createHeaderOnClickBehaviour(model));
headerWrapperDisplayName.add(createHeaderOnClickBehaviour(model));
VisibleEnableBehaviour visibleIfNotWrapper = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModelObject().isWrapper();
}
};
VisibleEnableBehaviour visibleIfWrapper = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject().isWrapper();
}
};
VisibleEnableBehaviour visibleIfExistingObject = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (getModelObject().isWrapper()) {
return false;
}
return isExistingViewableObject();
}
};
VisibleEnableBehaviour visibleIfNotWrapperAndNotExistingObject = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (getModelObject().isWrapper()) {
return false;
}
return !isExistingViewableObject();
}
};
headerChangeType.add(visibleIfNotWrapper);
headerObjectType.add(visibleIfNotWrapper);
headerNameLabel.add(visibleIfNotWrapperAndNotExistingObject);
headerNameLink.add(visibleIfExistingObject);
headerDescription.add(visibleIfNotWrapper);
headerWrapperDisplayName.add(visibleIfWrapper);
WebMarkupContainer body = new WebMarkupContainer(ID_BODY);
body.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
SceneDto wrapper = model.getObject();
return !wrapper.isMinimized();
}
});
box.add(body);
WebMarkupContainer itemsTable = new WebMarkupContainer(ID_ITEMS_TABLE);
itemsTable.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !model.getObject().getItems().isEmpty();
}
});
WebMarkupContainer oldValueLabel = new WebMarkupContainer(ID_OLD_VALUE_LABEL);
oldValueLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return model.getObject().containsDeltaItems();
}
});
itemsTable.add(oldValueLabel);
WebMarkupContainer newValueLabel = new WebMarkupContainer(ID_NEW_VALUE_LABEL);
newValueLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return model.getObject().containsDeltaItems();
}
});
itemsTable.add(newValueLabel);
WebMarkupContainer valueLabel = new WebMarkupContainer(ID_VALUE_LABEL);
valueLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !model.getObject().containsDeltaItems();
}
});
itemsTable.add(valueLabel);
ListView<SceneItemDto> items = new ListView<SceneItemDto>(ID_ITEMS, new PropertyModel<List<SceneItemDto>>(model, SceneDto.F_ITEMS)) {
@Override
protected void populateItem(ListItem<SceneItemDto> item) {
SceneItemPanel panel = new SceneItemPanel(ID_ITEM, item.getModel());
panel.setRenderBodyOnly(true);
item.add(panel);
}
};
items.setReuseItems(true);
itemsTable.add(items);
body.add(itemsTable);
ListView<SceneDto> partialScenes = new ListView<SceneDto>(ID_PARTIAL_SCENES, new PropertyModel<List<SceneDto>>(model, SceneDto.F_PARTIAL_SCENES)) {
@Override
protected void populateItem(ListItem<SceneDto> item) {
ScenePanel panel = new ScenePanel(ID_PARTIAL_SCENE, item.getModel());
panel.setOutputMarkupPlaceholderTag(true);
item.add(panel);
}
};
partialScenes.setReuseItems(true);
body.add(partialScenes);
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class AbstractRoleMemberPanel method createMembersColumns.
protected List<IColumn<SelectableBean<ObjectType>, String>> createMembersColumns() {
List<IColumn<SelectableBean<ObjectType>, String>> columns = new ArrayList<>();
IColumn<SelectableBean<ObjectType>, String> column = new AbstractExportableColumn<SelectableBean<ObjectType>, String>(createStringResource("TreeTablePanel.fullName.displayName")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ObjectType>>> cellItem, String componentId, IModel<SelectableBean<ObjectType>> rowModel) {
SelectableBean<ObjectType> bean = rowModel.getObject();
ObjectType object = bean.getValue();
cellItem.add(new Label(componentId, getMemberObjectDisplayName(object)));
}
@Override
public IModel<String> getDataModel(IModel<SelectableBean<ObjectType>> rowModel) {
return Model.of(getMemberObjectDisplayName(rowModel.getObject().getValue()));
}
};
columns.add(column);
column = new AbstractExportableColumn<SelectableBean<ObjectType>, String>(createStringResource("TreeTablePanel.identifier.description")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ObjectType>>> cellItem, String componentId, IModel<SelectableBean<ObjectType>> rowModel) {
SelectableBean<ObjectType> bean = rowModel.getObject();
ObjectType object = bean.getValue();
cellItem.add(new Label(componentId, getMemberObjectIdentifier(object)));
}
@Override
public IModel<String> getDataModel(IModel<SelectableBean<ObjectType>> rowModel) {
return Model.of(getMemberObjectIdentifier(rowModel.getObject().getValue()));
}
};
columns.add(column);
return columns;
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class AbstractRoleMemberPanel method initMemberTable.
private void initMemberTable(TableId tableId, Form form) {
WebMarkupContainer memberContainer = new WebMarkupContainer(ID_CONTAINER_MEMBER);
memberContainer.setOutputMarkupId(true);
memberContainer.setOutputMarkupPlaceholderTag(true);
form.add(memberContainer);
MainObjectListPanel<ObjectType> childrenListPanel = new MainObjectListPanel<ObjectType>(ID_MEMBER_TABLE, ObjectType.class, tableId, getSearchOptions(), getPageBase()) {
private static final long serialVersionUID = 1L;
@Override
protected void objectDetailsPerformed(AjaxRequestTarget target, ObjectType object) {
detailsPerformed(target, object);
}
@Override
protected boolean isClickable(IModel<SelectableBean<ObjectType>> rowModel) {
if (rowModel == null || rowModel.getObject() == null || rowModel.getObject().getValue() == null) {
return false;
}
Class<?> objectClass = rowModel.getObject().getValue().getClass();
return WebComponentUtil.hasDetailsPage(objectClass);
}
@Override
protected void newObjectPerformed(AjaxRequestTarget target) {
AbstractRoleMemberPanel.this.createFocusMemberPerformed(null, target);
}
@Override
protected List<IColumn<SelectableBean<ObjectType>, String>> createColumns() {
return createMembersColumns();
}
@Override
protected IColumn<SelectableBean<ObjectType>, String> createActionsColumn() {
return new InlineMenuHeaderColumn(createMembersHeaderInlineMenu());
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return new ArrayList<>();
}
@Override
protected ObjectQuery createContentQuery() {
ObjectQuery q = super.createContentQuery();
ObjectQuery members = AbstractRoleMemberPanel.this.createContentQuery();
List<ObjectFilter> filters = new ArrayList<>();
if (q != null && q.getFilter() != null) {
filters.add(q.getFilter());
}
if (members != null && members.getFilter() != null) {
filters.add(members.getFilter());
}
if (filters.size() == 1) {
return ObjectQuery.createObjectQuery(filters.iterator().next());
}
return ObjectQuery.createObjectQuery(AndFilter.createAnd(filters));
}
};
childrenListPanel.setOutputMarkupId(true);
memberContainer.add(childrenListPanel);
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class AccessCertificationCloseStageTriggerHandler method handle.
@Override
public <O extends ObjectType> void handle(PrismObject<O> prismObject, TriggerType trigger, Task task, OperationResult result) {
try {
ObjectType object = prismObject.asObjectable();
if (!(object instanceof AccessCertificationCampaignType)) {
LOGGER.error("Trigger of this type is supported only on {} objects, not on {}", AccessCertificationCampaignType.class.getSimpleName(), object.getClass().getName());
return;
}
AccessCertificationCampaignType campaign = (AccessCertificationCampaignType) object;
LOGGER.info("Automatically closing current stage of {}", ObjectTypeUtil.toShortString(campaign));
if (campaign.getState() != IN_REVIEW_STAGE) {
LOGGER.warn("Campaign {} is not in a review stage; this 'close stage' trigger will be ignored.", ObjectTypeUtil.toShortString(campaign));
return;
}
int currentStageNumber = campaign.getStageNumber();
certificationManager.closeCurrentStage(campaign.getOid(), currentStageNumber, task, result);
if (currentStageNumber < CertCampaignTypeUtil.getNumberOfStages(campaign)) {
LOGGER.info("Automatically opening next stage of {}", ObjectTypeUtil.toShortString(campaign));
certificationManager.openNextStage(campaign.getOid(), currentStageNumber + 1, task, result);
} else {
LOGGER.info("Automatically starting remediation for {}", ObjectTypeUtil.toShortString(campaign));
certificationManager.startRemediation(campaign.getOid(), task, result);
}
} catch (SchemaException | ObjectNotFoundException | ObjectAlreadyExistsException | SecurityViolationException | RuntimeException e) {
LoggingUtils.logException(LOGGER, "Couldn't close current campaign and possibly advance to the next one", e);
}
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class SearchEvaluator method evaluate.
public <T extends ObjectType> PipelineData evaluate(SearchExpressionType searchExpression, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException {
Validate.notNull(searchExpression.getType());
boolean noFetch = expressionHelper.getArgumentAsBoolean(searchExpression.getParameter(), PARAM_NO_FETCH, input, context, false, "search", globalResult);
@SuppressWarnings({ "unchecked", "raw" }) Class<T> objectClass = (Class<T>) ObjectTypes.getObjectTypeFromTypeQName(searchExpression.getType()).getClassDefinition();
ObjectQuery objectQuery = null;
if (searchExpression.getQuery() != null) {
try {
objectQuery = QueryJaxbConvertor.createObjectQuery(objectClass, searchExpression.getQuery(), prismContext);
} catch (SchemaException e) {
throw new ScriptExecutionException("Couldn't parse object query due to schema exception", e);
}
} else if (searchExpression.getSearchFilter() != null) {
// todo resolve variable references in the filter
objectQuery = new ObjectQuery();
try {
ObjectFilter filter = QueryConvertor.parseFilter(searchExpression.getSearchFilter(), objectClass, prismContext);
objectQuery.setFilter(filter);
} catch (SchemaException e) {
throw new ScriptExecutionException("Couldn't parse object filter due to schema exception", e);
}
}
final String variableName = searchExpression.getVariable();
final PipelineData oldVariableValue = variableName != null ? context.getVariable(variableName) : null;
final PipelineData outputData = PipelineData.createEmpty();
final MutableBoolean atLeastOne = new MutableBoolean(false);
ResultHandler<T> handler = (object, parentResult) -> {
context.checkTaskStop();
atLeastOne.setValue(true);
if (searchExpression.getScriptingExpression() != null) {
if (variableName != null) {
context.setVariable(variableName, PipelineData.create(object.getValue()));
}
JAXBElement<?> childExpression = searchExpression.getScriptingExpression();
try {
outputData.addAllFrom(scriptingExpressionEvaluator.evaluateExpression((ScriptingExpressionType) childExpression.getValue(), PipelineData.create(object.getValue()), context, globalResult));
globalResult.setSummarizeSuccesses(true);
globalResult.summarize();
} catch (ScriptExecutionException e) {
// todo think about this
if (context.isContinueOnAnyError()) {
LoggingUtils.logUnexpectedException(LOGGER, "Exception when evaluating item from search result list.", e);
} else {
throw new SystemException(e);
}
}
} else {
outputData.addValue(object.getValue());
}
return true;
};
try {
Collection<SelectorOptions<GetOperationOptions>> options = operationsHelper.createGetOptions(searchExpression.getOptions(), noFetch);
modelService.searchObjectsIterative(objectClass, objectQuery, handler, options, context.getTask(), globalResult);
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
// TODO continue on any error?
throw new ScriptExecutionException("Couldn't execute searchObjects operation: " + e.getMessage(), e);
}
if (atLeastOne.isFalse()) {
String matching = objectQuery != null ? "matching " : "";
// temporary hack, this will be configurable
context.println("Warning: no " + matching + searchExpression.getType().getLocalPart() + " object found");
}
if (variableName != null) {
context.setVariable(variableName, oldVariableValue);
}
return outputData;
}
Aggregations