use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.
the class OrgUnitAddDeletePopup method initLayout.
public void initLayout(WebMarkupContainer content) {
List<IColumn<SelectableBeanImpl<ObjectType>, String>> columns = initColumns();
ObjectQuery query = getDataProviderQuery();
ObjectDataProvider provider = new ObjectDataProvider(getPageBase(), null) {
@Override
public ObjectQuery getQuery() {
return query;
}
@Override
public Class getType() {
return OrgType.class;
}
};
TablePanel table = new TablePanel<>(ID_TABLE, provider, columns);
table.setOutputMarkupId(true);
content.add(table);
AjaxButton cancelButton = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("orgUnitAddDeletePopup.button.cancel")) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
cancelPerformed(ajaxRequestTarget);
}
};
content.add(cancelButton);
AjaxButton actionButton = new AjaxButton(ID_BUTTON_ACTION, createActionButtonStringResource()) {
@Override
public void onClick(AjaxRequestTarget target) {
actionPerformed(target);
}
};
actionButton.add(new AttributeAppender("class", getActionButtonClass()));
content.add(actionButton);
}
use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.
the class MidpointAbstractProvider method writeTo.
@Override
public void writeTo(T object, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
// TODO implement in the standard serializer; also change root name
QName fakeQName = new QName(PrismConstants.NS_TYPES, "object");
String serializedForm;
PrismSerializer<String> serializer = getSerializer().options(SerializationOptions.createSerializeReferenceNames());
try {
if (object instanceof ObjectType) {
ObjectType ot = (ObjectType) object;
serializedForm = serializer.serialize(ot.asPrismObject());
} else if (object instanceof PrismObject) {
serializedForm = serializer.serialize((PrismObject<?>) object);
} else if (object instanceof OperationResult) {
Function<LocalizableMessage, String> resolveKeys = msg -> localizationService.translate(msg, Locale.US);
OperationResultType operationResultType = ((OperationResult) object).createOperationResultType(resolveKeys);
serializedForm = serializer.serializeAnyData(operationResultType, fakeQName);
} else {
serializedForm = serializer.serializeAnyData(object, fakeQName);
}
entityStream.write(serializedForm.getBytes(StandardCharsets.UTF_8));
} catch (SchemaException | RuntimeException e) {
LoggingUtils.logException(LOGGER, "Couldn't marshal element to string: {}", e, object);
}
}
use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.
the class MultiValueObjectChoosePanel method initEmptyModelInputPanel.
private void initEmptyModelInputPanel() {
WebMarkupContainer emptyModelContainer = new WebMarkupContainer(ID_EMPTY_MODEL_CONTAINER);
emptyModelContainer.setOutputMarkupId(true);
emptyModelContainer.add(new VisibleBehaviour(() -> isEmptyModel() || emptyObjectPanelDisplay));
add(emptyModelContainer);
ValueChoosePanel<R> emptyModelPanel = new ValueChoosePanel<R>(ID_EMPTY_MODEL_INPUT, new IModel<R>() {
@Override
public R getObject() {
return null;
}
}) {
private static final long serialVersionUID = 1L;
@Override
protected ObjectFilter createCustomFilter() {
return MultiValueObjectChoosePanel.this.createCustomFilter();
}
@Override
public List<QName> getSupportedTypes() {
return MultiValueObjectChoosePanel.this.getSupportedTypes();
}
@Override
protected <O extends ObjectType> void choosePerformed(AjaxRequestTarget target, O object) {
emptyObjectPanelDisplay = false;
chooseObjectPerformed(target, object);
target.add(MultiValueObjectChoosePanel.this);
}
};
emptyModelPanel.setOutputMarkupId(true);
emptyModelContainer.add(emptyModelPanel);
WebMarkupContainer buttonsWhenEmptyContainer = new WebMarkupContainer(ID_BUTTONS_WHEN_EMPTY_CONTAINER);
buttonsWhenEmptyContainer.setOutputMarkupId(true);
emptyModelContainer.add(buttonsWhenEmptyContainer);
AjaxButton addWhenEmptyButton = new AjaxButton(ID_ADD_WHEN_EMPTY_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
// will be disabled all the time, nothing to do here
}
};
addWhenEmptyButton.setOutputMarkupId(true);
addWhenEmptyButton.add(new EnableBehaviour(() -> false));
buttonsWhenEmptyContainer.add(addWhenEmptyButton);
AjaxButton removeWhenEmptyButton = new AjaxButton(ID_REMOVE_WHEN_EMPTY_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
// will be disabled all the time, nothing to do here
}
};
removeWhenEmptyButton.setOutputMarkupId(true);
removeWhenEmptyButton.add(new EnableBehaviour(() -> false));
buttonsWhenEmptyContainer.add(removeWhenEmptyButton);
}
use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.
the class PreviewChangesTabPanel method initModels.
private void initModels() {
final List<ObjectDelta<? extends ObjectType>> primaryDeltas = new ArrayList<>();
final List<ObjectDelta<? extends ObjectType>> secondaryDeltas = new ArrayList<>();
final List<? extends Scene> primaryScenes;
final List<? extends Scene> secondaryScenes;
ModelContext<O> modelContext = getModelObject();
try {
if (modelContext != null) {
if (modelContext.getFocusContext() != null) {
addIgnoreNull(primaryDeltas, CloneUtil.clone(modelContext.getFocusContext().getPrimaryDelta()));
ObjectDelta<O> summarySecondaryDelta = CloneUtil.clone(modelContext.getFocusContext().getSummarySecondaryDelta());
if (summarySecondaryDelta != null && !summarySecondaryDelta.getModifications().isEmpty()) {
secondaryDeltas.add(summarySecondaryDelta);
}
}
for (ModelProjectionContext projCtx : modelContext.getProjectionContexts()) {
ObjectDelta<ShadowType> primaryDelta = CloneUtil.clone(projCtx.getPrimaryDelta());
addIgnoreNull(primaryDeltas, primaryDelta);
if (!isEquivalentWithoutOperationAttr(primaryDelta, CloneUtil.clone(projCtx.getExecutableDelta()))) {
addIgnoreNull(secondaryDeltas, CloneUtil.clone(projCtx.getExecutableDelta()));
}
}
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Primary deltas:\n{}", DebugUtil.debugDump(primaryDeltas));
LOGGER.trace("Secondary deltas:\n{}", DebugUtil.debugDump(secondaryDeltas));
}
Task task = getPageBase().createSimpleTask("visualize");
primaryScenes = getPageBase().getModelInteractionService().visualizeDeltas(primaryDeltas, task, task.getResult());
secondaryScenes = getPageBase().getModelInteractionService().visualizeDeltas(secondaryDeltas, task, task.getResult());
} catch (SchemaException | ExpressionEvaluationException e) {
// TODO
throw new SystemException(e);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Creating context DTO for primary deltas:\n{}", DebugUtil.debugDump(primaryScenes));
LOGGER.trace("Creating context DTO for secondary deltas:\n{}", DebugUtil.debugDump(secondaryScenes));
}
final WrapperScene primaryScene = new WrapperScene(primaryScenes, primaryScenes.size() != 1 ? "PagePreviewChanges.primaryChangesMore" : "PagePreviewChanges.primaryChangesOne", primaryScenes.size());
final WrapperScene secondaryScene = new WrapperScene(secondaryScenes, secondaryScenes.size() != 1 ? "PagePreviewChanges.secondaryChangesMore" : "PagePreviewChanges.secondaryChangesOne", secondaryScenes.size());
final SceneDto primarySceneDto = new SceneDto(primaryScene);
final SceneDto secondarySceneDto = new SceneDto(secondaryScene);
primaryDeltasModel = (IModel<SceneDto>) () -> primarySceneDto;
secondaryDeltasModel = (IModel<SceneDto>) () -> secondarySceneDto;
PolicyRuleEnforcerPreviewOutputType enforcements = modelContext != null ? modelContext.getPolicyRuleEnforcerPreviewOutput() : null;
List<EvaluatedTriggerGroupDto> triggerGroups = enforcements != null ? Collections.singletonList(EvaluatedTriggerGroupDto.initializeFromRules(enforcements.getRule(), false, null)) : Collections.emptyList();
policyViolationsModel = Model.ofList(triggerGroups);
List<ApprovalSchemaExecutionInformationType> approvalsExecutionList = modelContext != null ? modelContext.getHookPreviewResults(ApprovalSchemaExecutionInformationType.class) : Collections.emptyList();
List<ApprovalProcessExecutionInformationDto> approvals = new ArrayList<>();
if (!approvalsExecutionList.isEmpty()) {
// TODO
Task opTask = getPageBase().createSimpleTask(PagePreviewChanges.class + ".createApprovals");
OperationResult result = opTask.getResult();
ObjectResolver modelObjectResolver = getPageBase().getModelObjectResolver();
try {
for (ApprovalSchemaExecutionInformationType execution : approvalsExecutionList) {
approvals.add(ApprovalProcessExecutionInformationDto.createFrom(execution, modelObjectResolver, true, opTask, // TODO reuse session
result));
}
result.computeStatus();
} catch (Throwable t) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't prepare approval information", t);
result.recordFatalError(createStringResource("PreviewChangesTabPanel.message.prepareApproval.fatalError", t.getMessage()).getString(), t);
}
if (WebComponentUtil.showResultInPage(result)) {
getPageBase().showResult(result);
}
}
approvalsModel = Model.ofList(approvals);
}
use of org.mitre.cybox.cybox_2.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 IModel<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 IModel<String>() {
@Override
public String getObject() {
return model.getObject().getName(ScenePanel.this);
}
};
Label headerNameLabel = new Label(ID_HEADER_NAME_LABEL, nameModel);
AjaxLinkPanel headerNameLink = new AjaxLinkPanel(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().getPrismContext()), getPageBase(), false);
}
}
};
Label headerDescription = new Label(ID_HEADER_DESCRIPTION, new IModel<String>() {
@Override
public String getObject() {
return model.getObject().getDescription(ScenePanel.this);
}
});
Label headerWrapperDisplayName = new Label(ID_HEADER_WRAPPER_DISPLAY_NAME, new IModel<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 visibleIfExistingObjectAndAuthorized = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (getModelObject().isWrapper()) {
return false;
}
return isExistingViewableObject() && isAutorized();
}
};
VisibleEnableBehaviour visibleIfNotWrapperAndNotExistingObjectAndNotAuthorized = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (getModelObject().isWrapper()) {
return false;
}
return !isExistingViewableObject() || !isAutorized();
}
};
headerChangeType.add(visibleIfNotWrapper);
headerObjectType.add(visibleIfNotWrapper);
headerNameLabel.add(visibleIfNotWrapperAndNotExistingObjectAndNotAuthorized);
headerNameLink.add(visibleIfExistingObjectAndAuthorized);
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();
}
});
itemsTable.setOutputMarkupId(true);
ToggleIconButton<String> sortPropertiesButton = new ToggleIconButton<String>(ID_SORT_PROPERTIES, GuiStyleConstants.CLASS_ICON_SORT_ALPHA_ASC, GuiStyleConstants.CLASS_ICON_SORT_AMOUNT_ASC) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
onSortClicked(model, target);
}
@Override
public boolean isOn() {
return model.getObject().isSorted();
}
};
sortPropertiesButton.setOutputMarkupId(true);
sortPropertiesButton.setOutputMarkupPlaceholderTag(true);
itemsTable.add(sortPropertiesButton);
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<>(model, SceneDto.F_ITEMS)) {
@Override
protected void populateItem(ListItem<SceneItemDto> item) {
SceneItemPanel panel = new SceneItemPanel(ID_ITEM, item.getModel());
panel.add(new VisibleBehaviour(() -> !isOperationalItem(item.getModel()) || isOperationalItemsVisible()));
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<>(model, SceneDto.F_PARTIAL_SCENES)) {
@Override
protected void populateItem(ListItem<SceneDto> item) {
ScenePanel panel = new ScenePanel(ID_PARTIAL_SCENE, item.getModel()) {
private static final long serialVersionUID = 1L;
@Override
protected boolean isOperationalItemsVisible() {
ScenePanel parentScenePanel = findParent(ScenePanel.class);
if (parentScenePanel != null) {
return parentScenePanel.isOperationalItemsVisible();
} else {
return ScenePanel.this.operationalItemsVisible;
}
}
};
panel.add(new VisibleBehaviour(() -> !isOperationalPartialScene(item.getModel()) || operationalItemsVisible));
panel.setOutputMarkupPlaceholderTag(true);
item.add(panel);
}
};
partialScenes.setReuseItems(true);
body.add(partialScenes);
AjaxButton showOperationalItemsLink = new AjaxButton(ID_SHOW_OPERATIONAL_ITEMS_LINK) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
setOperationalItemsVisible(!operationalItemsVisible);
target.add(ScenePanel.this);
}
@Override
public IModel<?> getBody() {
return getShowOperationalItemsLinkLabel();
}
};
showOperationalItemsLink.setOutputMarkupId(true);
showOperationalItemsLink.add(AttributeAppender.append("style", "cursor: pointer;"));
showOperationalItemsLink.add(new VisibleBehaviour(() -> showOperationalItems));
body.add(showOperationalItemsLink);
}
Aggregations