use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.
the class AuditLogViewerPanel method initColumns.
protected List<IColumn<AuditEventRecordType, String>> initColumns() {
List<IColumn<AuditEventRecordType, String>> columns = new ArrayList<IColumn<AuditEventRecordType, String>>();
IColumn<AuditEventRecordType, String> linkColumn = new LinkColumn<AuditEventRecordType>(createStringResource("AuditEventRecordType.timestamp"), "timestamp") {
private static final long serialVersionUID = 1L;
@Override
protected IModel<String> createLinkModel(final IModel<AuditEventRecordType> rowModel) {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
XMLGregorianCalendar time = rowModel.getObject().getTimestamp();
return WebComponentUtil.formatDate(time);
}
};
}
@Override
public void onClick(AjaxRequestTarget target, IModel<AuditEventRecordType> rowModel) {
AuditEventRecordType record = rowModel.getObject();
try {
AuditEventRecord.adopt(record, pageBase.getPrismContext());
} catch (SchemaException e) {
throw new SystemException("Couldn't adopt event record: " + e, e);
}
pageBase.navigateToNext(new PageAuditLogDetails(record));
}
};
columns.add(linkColumn);
PropertyColumn<AuditEventRecordType, String> initiatorRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.initiatorRef"), AuditEventRecordType.F_INITIATOR_REF.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
AuditEventRecordType auditEventRecordType = rowModel.getObject();
createReferenceColumn(auditEventRecordType.getInitiatorRef(), item, componentId);
}
};
columns.add(initiatorRefColumn);
if (visibilityMap == null || visibilityMap.get(EVENT_STAGE_COLUMN_VISIBILITY) == null || visibilityMap.get(EVENT_STAGE_COLUMN_VISIBILITY)) {
IColumn<AuditEventRecordType, String> eventStageColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventStageLabel"), "eventStage");
columns.add(eventStageColumn);
}
IColumn<AuditEventRecordType, String> eventTypeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventTypeLabel"), "eventType");
columns.add(eventTypeColumn);
if (visibilityMap == null || visibilityMap.get(TARGET_COLUMN_VISIBILITY) == null || visibilityMap.get(TARGET_COLUMN_VISIBILITY)) {
PropertyColumn<AuditEventRecordType, String> targetRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.targetRef"), AuditEventRecordType.F_TARGET_REF.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
createReferenceColumn(auditEventRecordType.getTargetRef(), item, componentId);
}
};
columns.add(targetRefColumn);
}
if (visibilityMap == null || visibilityMap.get(TARGET_OWNER_COLUMN_VISIBILITY) == null || visibilityMap.get(TARGET_OWNER_COLUMN_VISIBILITY)) {
PropertyColumn<AuditEventRecordType, String> targetOwnerRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.targetOwnerRef"), AuditEventRecordType.F_TARGET_OWNER_REF.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
createReferenceColumn(auditEventRecordType.getTargetOwnerRef(), item, componentId);
}
};
columns.add(targetOwnerRefColumn);
}
IColumn<AuditEventRecordType, String> channelColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.channel"), "channel") {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
String channel = auditEventRecordType.getChannel();
if (channel != null) {
QName channelQName = QNameUtil.uriToQName(channel);
String return_ = channelQName.getLocalPart();
item.add(new Label(componentId, return_));
} else {
item.add(new Label(componentId, ""));
}
item.add(new AttributeModifier("style", new Model<String>("width: 10%;")));
}
};
columns.add(channelColumn);
IColumn<AuditEventRecordType, String> outcomeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.outcomeLabel"), "outcome");
columns.add(outcomeColumn);
return columns;
}
use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.
the class ResourceConnectorPanel method initLayout.
private void initLayout(final IModel<PrismObject<ResourceType>> model, final PageBase parentPage) {
setOutputMarkupId(true);
IModel<List<ConnectorOperationalStatus>> statsModel = new AbstractReadOnlyModel<List<ConnectorOperationalStatus>>() {
private static final long serialVersionUID = 1L;
@Override
public List<ConnectorOperationalStatus> getObject() {
PrismObject<ResourceType> resource = model.getObject();
Task task = parentPage.createSimpleTask(OPERATION_GET_CONNECTOR_OPERATIONAL_STATUS);
OperationResult result = task.getResult();
List<ConnectorOperationalStatus> status = null;
try {
status = parentPage.getModelInteractionService().getConnectorOperationalStatus(resource.getOid(), task, result);
} catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
LOGGER.error("Error getting connector status for {}: {}", resource, e.getMessage(), e);
parentPage.showResult(result);
}
return status;
}
};
ListView<ConnectorOperationalStatus> listview = new ListView<ConnectorOperationalStatus>(ID_CONNECTOR_LIST, statsModel) {
private static final long serialVersionUID = 1L;
protected void populateItem(ListItem<ConnectorOperationalStatus> item) {
item.add(new Label("label", item.getModel()));
IModel<ConnectorOperationalStatus> statModel = item.getModel();
item.add(createLabel(statModel, ID_CONNECTOR_NAME, ConnectorOperationalStatus.F_CONNECTOR_NAME));
item.add(createLabel(statModel, ID_CONNECOTR_CLASS, ConnectorOperationalStatus.F_CONNECTOR_CLASS_NAME));
item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_SIZE, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_SIZE));
item.add(createLabel(statModel, ID_POOL_CONFIG_MAX_SIZE, ConnectorOperationalStatus.F_POOL_CONFIG_MAX_SIZE));
item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_IDLE, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_IDLE));
item.add(createLabel(statModel, ID_POOL_CONFIG_MAX_IDLE, ConnectorOperationalStatus.F_POOL_CONFIG_MAX_IDLE));
item.add(createLabel(statModel, ID_POOL_CONFIG_WAIT_TIMEOUT, ConnectorOperationalStatus.F_POOL_CONFIG_WAIT_TIMEOUT));
item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_EVICTABLE_IDLE_TIME, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_EVICTABLE_IDLE_TIME));
item.add(createLabel(statModel, ID_POOL_STATUS_NUM_IDLE, ConnectorOperationalStatus.F_POOL_STATUS_NUM_IDLE));
item.add(createLabel(statModel, ID_POOL_STATUS_NUM_ACTIVE, ConnectorOperationalStatus.F_POOL_STATUS_NUM_ACTIVE));
}
};
add(listview);
}
use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.
the class ResourceContentPanel method createDeleteConfirmString.
private IModel<String> createDeleteConfirmString(final ShadowType selected, final String oneDeleteKey, final String moreDeleteKey) {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
List<ShadowType> selectedShadow = getSelectedShadowsList(selected);
switch(selectedShadow.size()) {
case 1:
Object first = selectedShadow.get(0);
String name = WebComponentUtil.getName(((ShadowType) first));
return getPageBase().createStringResource(oneDeleteKey, name).getString();
default:
return getPageBase().createStringResource(moreDeleteKey, selectedShadow.size()).getString();
}
}
};
}
use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.
the class RunReportPopupPanel method createResourceListModel.
private IModel<List<String>> createResourceListModel() {
OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
Task task = createSimpleTask(OPERATION_LOAD_RESOURCES);
List<PrismObject<ResourceType>> resources = null;
final List<String> resourceList = new ArrayList();
try {
resources = getPageBase().getModelService().searchObjects(ResourceType.class, new ObjectQuery(), null, task, result);
} catch (Exception ex) {
LOGGER.error(ex.getMessage());
}
for (PrismObject<ResourceType> resource : resources) {
resourceList.add(resource.getBusinessDisplayName());
}
return new AbstractReadOnlyModel<List<String>>() {
@Override
public List<String> getObject() {
return resourceList;
}
};
}
use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.
the class PageResources method createDeleteConfirmString.
/**
* @param oneDeleteKey
* message if deleting one item
* @param moreDeleteKey
* message if deleting more items
* @param resources
* if true selecting resources if false selecting from hosts
*/
private IModel<String> createDeleteConfirmString(final String oneDeleteKey, final String moreDeleteKey, final boolean resources) {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
List selected = new ArrayList();
if (singleDelete != null) {
selected.add(singleDelete);
} else {
selected = getResourceTable().getSelectedObjects();
}
switch(selected.size()) {
case 1:
Object first = selected.get(0);
String name = WebComponentUtil.getName(((ResourceType) first));
return createStringResource(oneDeleteKey, name).getString();
default:
return createStringResource(moreDeleteKey, selected.size()).getString();
}
}
};
}
Aggregations