use of com.evolveum.midpoint.gui.impl.GuiChannel in project midpoint by Evolveum.
the class ProvenanceAcquisitionHeaderPanel method initLayout.
private void initLayout() {
LinkedReferencePanel<ObjectReferenceType> source = new LinkedReferencePanel<>(ID_SOURCE, new ReadOnlyModel<>(() -> {
ProvenanceAcquisitionType acquisitionType = getModelObject();
if (acquisitionType == null) {
return null;
}
ObjectReferenceType ref = acquisitionType.getResourceRef();
if (ref != null && ref.getOid() != null) {
return ref;
}
ObjectReferenceType originRef = acquisitionType.getOriginRef();
if (originRef != null && originRef.getOid() != null) {
return originRef;
}
return null;
}));
add(source);
source.add(new VisibleBehaviour(() -> isNotEmpty(getModelObject().getResourceRef()) || isNotEmpty(getModelObject().getOriginRef())));
ReadOnlyModel<GuiChannel> channelModel = new ReadOnlyModel<>(() -> GuiChannel.findChannel(getModelObject().getChannel()));
WebMarkupContainer channelIcon = new WebMarkupContainer(ID_CHANNEL_ICON);
add(channelIcon);
channelIcon.add(AttributeAppender.replace("class", new PropertyModel<>(channelModel, "iconCssClass")));
Label channel = new Label(ID_CHANNEL, getPageBase().createStringResource(channelModel.getObject()));
add(channel);
channel.add(new VisibleBehaviour(() -> getModelObject() != null && (getModelObject().getOriginRef() == null || getModelObject().getOriginRef().getOid() == null) && (getModelObject().getResourceRef() == null || getModelObject().getResourceRef().getOid() == null)));
}
use of com.evolveum.midpoint.gui.impl.GuiChannel in project midpoint by Evolveum.
the class AuditLogViewerPanel method createColumns.
protected List<IColumn<SelectableBean<AuditEventRecordType>, String>> createColumns() {
List<IColumn<SelectableBean<AuditEventRecordType>, String>> columns = new ArrayList<>();
LinkColumn<SelectableBean<AuditEventRecordType>> initiatorRefColumn = new LinkColumn<>(createStringResource("AuditEventRecordType.initiatorRef"), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_INITIATOR_REF.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
protected IModel<String> createLinkModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
return new ReadOnlyModel<>(() -> {
AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
if (auditEventRecordType == null) {
return null;
}
return WebModelServiceUtils.resolveReferenceName(auditEventRecordType.getInitiatorRef(), getPageBase(), true);
});
}
@Override
public void onClick(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
dispatchToObjectDetailsPage(auditEventRecordType.getInitiatorRef(), getPageBase(), false);
}
@Override
public boolean isEnabled(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
return unwrapModel(rowModel) != null;
}
};
columns.add(initiatorRefColumn);
if (!isObjectHistoryPanel()) {
IColumn<SelectableBean<AuditEventRecordType>, String> eventStageColumn = new PropertyColumn<>(createStringResource("PageAuditLogViewer.eventStageLabel"), AuditEventRecordType.F_EVENT_STAGE.getLocalPart(), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_EVENT_STAGE.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public IModel<String> getDataModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
AuditEventRecordType record = unwrapModel(rowModel);
if (record == null) {
return new Model<>();
}
return WebComponentUtil.createLocalizedModelForEnum(record.getEventStage(), AuditLogViewerPanel.this);
}
};
columns.add(eventStageColumn);
}
IColumn<SelectableBean<AuditEventRecordType>, String> eventTypeColumn = new PropertyColumn<>(createStringResource("PageAuditLogViewer.eventTypeLabel"), AuditEventRecordType.F_EVENT_TYPE.getLocalPart(), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_EVENT_TYPE.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public IModel<String> getDataModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
AuditEventRecordType record = unwrapModel(rowModel);
if (record == null) {
return Model.of();
}
return WebComponentUtil.createLocalizedModelForEnum(record.getEventType(), AuditLogViewerPanel.this);
}
};
columns.add(eventTypeColumn);
if (!isObjectHistoryPanel()) {
LinkColumn<SelectableBean<AuditEventRecordType>> targetRefColumn = new LinkColumn<>(createStringResource("AuditEventRecordType.targetRef"), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_TARGET_REF.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
protected IModel<String> createLinkModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
return new ReadOnlyModel<>(() -> {
AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
if (auditEventRecordType == null) {
return null;
}
return WebModelServiceUtils.resolveReferenceName(auditEventRecordType.getTargetRef(), getPageBase(), true);
});
}
@Override
public boolean isEnabled(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
return unwrapModel(rowModel) != null && !AuditEventTypeType.DELETE_OBJECT.equals(unwrapModel(rowModel).getEventType());
}
@Override
public void onClick(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
dispatchToObjectDetailsPage(auditEventRecordType.getTargetRef(), getPageBase(), false);
}
};
columns.add(targetRefColumn);
}
if (!isObjectHistoryPanel()) {
LinkColumn<SelectableBean<AuditEventRecordType>> targetOwnerRefColumn = new LinkColumn<>(createStringResource("AuditEventRecordType.targetOwnerRef"), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_TARGET_OWNER_REF.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
protected IModel<String> createLinkModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
return new ReadOnlyModel<>(() -> {
AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
if (auditEventRecordType == null) {
return null;
}
return WebModelServiceUtils.resolveReferenceName(auditEventRecordType.getTargetOwnerRef(), getPageBase(), true);
});
}
@Override
public void onClick(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
dispatchToObjectDetailsPage(auditEventRecordType.getTargetOwnerRef(), getPageBase(), false);
}
@Override
public boolean isEnabled(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
return unwrapModel(rowModel) != null;
}
};
columns.add(targetOwnerRefColumn);
}
IColumn<SelectableBean<AuditEventRecordType>, String> channelColumn = new PropertyColumn<>(createStringResource("AuditEventRecordType.channel"), AuditEventRecordType.F_CHANNEL.getLocalPart(), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_CHANNEL.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<AuditEventRecordType>>> item, String componentId, IModel<SelectableBean<AuditEventRecordType>> rowModel) {
IModel<String> channelModel = new ReadOnlyModel<String>(() -> {
AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
if (auditEventRecordType == null) {
// TODO might we return null?
return "";
}
String channel = auditEventRecordType.getChannel();
for (GuiChannel chan : GuiChannel.values()) {
if (chan.getUri().equals(channel)) {
// WebComponentUtil.createLocalizedModelForEnum(chan, AuditLogViewerPanel.this);
return getPageBase().createStringResource(chan).getString();
}
}
return "";
});
// if (channelValue != null) {
// item.add(new Label(componentId, WebComponentUtil.createLocalizedModelForEnum(channelValue, AuditLogViewerPanel.this)));
// } else {
// item.add(new Label(componentId, ""));
// }
item.add(new Label(componentId, channelModel));
item.add(new AttributeModifier("style", new Model<>("width: 10%;")));
}
};
columns.add(channelColumn);
IColumn<SelectableBean<AuditEventRecordType>, String> outcomeColumn = new PropertyColumn<>(createStringResource("PageAuditLogViewer.outcomeLabel"), AuditEventRecordType.F_OUTCOME.getLocalPart(), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_OUTCOME.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public IModel<String> getDataModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
AuditEventRecordType record = unwrapModel(rowModel);
if (record == null) {
return null;
}
return WebComponentUtil.createLocalizedModelForEnum(record.getOutcome(), AuditLogViewerPanel.this);
}
};
columns.add(outcomeColumn);
return columns;
}
Aggregations