use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class ResourceDetailsTabPanel method determineActivationMappings.
private SourceTarget determineActivationMappings(ResourceType resource) {
if (resource.getSchemaHandling() != null && CollectionUtils.isNotEmpty(resource.getSchemaHandling().getObjectType())) {
boolean hasOutbound = false;
boolean hasInbound = false;
for (ResourceObjectTypeDefinitionType resourceObjectTypeDefinition : resource.getSchemaHandling().getObjectType()) {
if (hasInbound && hasOutbound) {
return SourceTarget.SOURCE_TARGET;
}
if (resourceObjectTypeDefinition.getActivation() == null) {
continue;
}
if (!hasOutbound) {
ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
if (activationDef.getAdministrativeStatus() != null && CollectionUtils.isNotEmpty(activationDef.getAdministrativeStatus().getOutbound())) {
hasOutbound = true;
}
}
if (!hasOutbound) {
ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
if (activationDef.getValidFrom() != null && CollectionUtils.isNotEmpty(activationDef.getValidFrom().getOutbound())) {
hasOutbound = true;
}
}
if (!hasOutbound) {
ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
if (activationDef.getValidTo() != null && CollectionUtils.isNotEmpty(activationDef.getValidTo().getOutbound())) {
hasOutbound = true;
}
}
if (!hasOutbound) {
ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
if (activationDef.getExistence() != null && CollectionUtils.isNotEmpty(activationDef.getExistence().getOutbound())) {
hasOutbound = true;
}
}
if (!hasInbound) {
ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
if (activationDef.getAdministrativeStatus() != null && CollectionUtils.isNotEmpty(activationDef.getAdministrativeStatus().getInbound())) {
hasInbound = true;
}
}
if (!hasInbound) {
ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
if (activationDef.getValidFrom() != null && CollectionUtils.isNotEmpty(activationDef.getValidFrom().getInbound())) {
hasInbound = true;
}
}
if (!hasInbound) {
ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
if (activationDef.getValidTo() != null && CollectionUtils.isNotEmpty(activationDef.getValidTo().getInbound())) {
hasInbound = true;
}
}
if (!hasInbound) {
ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
if (activationDef.getExistence() != null && CollectionUtils.isNotEmpty(activationDef.getExistence().getInbound())) {
hasInbound = true;
}
}
}
if (hasInbound) {
return SourceTarget.SOURCE;
}
if (hasOutbound) {
return SourceTarget.TARGET;
}
}
return SourceTarget.NOT_DEFINED;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class ResourceDetailsTabPanel method createLastAvailabilityStatusInfo.
private InfoBoxPanel createLastAvailabilityStatusInfo(ResourceType resource) {
String messageKey = "PageResource.resource.availabilityUnknown";
String backgroundColor = "bg-gray";
String icon = "fa-question";
OperationalStateType operationalState = resource.getOperationalState();
if (operationalState != null) {
AvailabilityStatusType lastAvailabilityStatus = operationalState.getLastAvailabilityStatus();
if (lastAvailabilityStatus != null) {
if (lastAvailabilityStatus == AvailabilityStatusType.UP) {
messageKey = "PageResource.resource.up";
backgroundColor = "bg-green";
icon = "fa-power-off";
} else if (lastAvailabilityStatus == AvailabilityStatusType.DOWN) {
backgroundColor = "bg-red";
messageKey = "PageResource.resource.down";
icon = "fa-ban";
} else if (lastAvailabilityStatus == AvailabilityStatusType.BROKEN) {
backgroundColor = "bg-yellow";
messageKey = "PageResource.resource.broken";
icon = "fa-warning";
}
}
}
InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, icon, parentPage.getString(messageKey));
ConnectorType connectorType = resource.getConnector();
if (connectorType == null) {
// Connector not found. Probably bad connectorRef reference.
infoBoxType.setNumber("--");
infoBoxType.setDescription("--");
} else {
String connectorName = StringUtils.substringAfterLast(WebComponentUtil.getEffectiveName(connectorType, ConnectorType.F_CONNECTOR_TYPE), ".");
String connectorVersion = connectorType.getConnectorVersion();
infoBoxType.setNumber(connectorName);
infoBoxType.setDescription(connectorVersion);
}
Model<InfoBoxType> boxModel = new Model<InfoBoxType>(infoBoxType);
InfoBoxPanel lastAvailabilityStatus = new InfoBoxPanel(ID_LAST_AVAILABILITY_STATUS, boxModel);
lastAvailabilityStatus.setOutputMarkupId(true);
return lastAvailabilityStatus;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class ResourceDetailsTabPanel method getTaskFor.
private List<TaskType> getTaskFor(List<PrismObject<TaskType>> tasks, ObjectSynchronizationType synchronizationPolicy, PrismObject<ResourceType> resource) throws SchemaException {
List<TaskType> syncTasks = new ArrayList<TaskType>();
for (PrismObject<TaskType> task : tasks) {
PrismProperty<ShadowKindType> taskKind = task.findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_KIND));
ShadowKindType taskKindValue = null;
if (taskKind != null) {
taskKindValue = taskKind.getRealValue();
}
PrismProperty<String> taskIntent = task.findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_INTENT));
String taskIntentValue = null;
if (taskIntent != null) {
taskIntentValue = taskIntent.getRealValue();
}
PrismProperty<QName> taskObjectClass = task.findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.OBJECTCLASS_PROPERTY_NAME));
QName taskObjectClassValue = null;
if (taskObjectClass != null) {
taskObjectClassValue = taskObjectClass.getRealValue();
}
// is not accessible in admin-gui)
if (taskObjectClassValue == null) {
ObjectClassComplexTypeDefinition taskObjectClassDef = null;
RefinedResourceSchema schema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
if (schema == null) {
throw new SchemaException("No schema defined in resource. Possible configuration problem?");
}
if (taskKindValue == null && taskIntentValue == null) {
taskObjectClassDef = schema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
}
if (taskKindValue != null) {
if (StringUtils.isEmpty(taskIntentValue)) {
taskObjectClassDef = schema.findDefaultObjectClassDefinition(taskKindValue);
} else {
taskObjectClassDef = schema.findObjectClassDefinition(taskKindValue, taskIntentValue);
}
}
if (taskObjectClassDef != null) {
taskObjectClassValue = taskObjectClassDef.getTypeName();
}
}
if (SynchronizationUtils.isPolicyApplicable(taskObjectClassValue, taskKindValue, taskIntentValue, synchronizationPolicy, resource)) {
syncTasks.add(task.asObjectable());
}
}
return syncTasks;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class ResourceDetailsTabPanel method initLayout.
protected void initLayout(IModel model, PageBase parentPage) {
PrismObject<ResourceType> resourceObject = (PrismObject<ResourceType>) model.getObject();
ResourceType resource = resourceObject.asObjectable();
add(createLastAvailabilityStatusInfo(resource));
add(createSourceTargetInfo(resource));
add(createSchemaStatusInfo(resource));
CapabilitiesPanel capabilities = new CapabilitiesPanel(PANEL_CAPABILITIES, capabilitiesModel);
add(capabilities);
List<ResourceConfigurationDto> resourceConfigList = createResourceConfigList(resource);
ListDataProvider<ResourceConfigurationDto> resourceConfigProvider = new ListDataProvider<ResourceConfigurationDto>(ResourceDetailsTabPanel.this, new ListModel<ResourceConfigurationDto>(resourceConfigList));
List<ColumnTypeDto<String>> columns = Arrays.asList(new ColumnTypeDto<String>("ShadowType.kind", "objectTypeDefinition.kind", ShadowType.F_KIND.getLocalPart()), new ColumnTypeDto<String>("ShadowType.objectClass", "objectTypeDefinition.objectClass.localPart", ShadowType.F_OBJECT_CLASS.getLocalPart()), new ColumnTypeDto<String>("ShadowType.intent", "objectTypeDefinition.intent", ShadowType.F_INTENT.getLocalPart()), new ColumnTypeDto<String>("ResourceType.isSync", "sync", null));
List<IColumn<SelectableBean<ResourceType>, String>> tableColumns = ColumnUtils.createColumns(columns);
PropertyColumn tasksColumn = new PropertyColumn(PageBase.createStringResourceStatic(this, "ResourceType.tasks"), "definedTasks") {
@Override
public void populateItem(Item item, String componentId, final IModel rowModel) {
ResourceConfigurationDto conf = (ResourceConfigurationDto) rowModel.getObject();
RepeatingView repeater = new RepeatingView(componentId);
for (final TaskType task : conf.getDefinedTasks()) {
repeater.add(new LinkPanel(repeater.newChildId(), new Model<String>(task.getName().getOrig())) {
@Override
public void onClick(AjaxRequestTarget target) {
ResourceDetailsTabPanel.this.taskDetailsPerformed(target, task.getOid());
}
});
}
item.add(repeater);
}
};
tableColumns.add(tasksColumn);
BoxedTablePanel<ResourceConfigurationDto> resourceConfig = new BoxedTablePanel("resourceConfig", resourceConfigProvider, tableColumns);
resourceConfig.setAdditionalBoxCssClasses("box-success");
add(resourceConfig);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class ResourceDetailsTabPanel method determineIfSourceOrTarget.
private SourceTarget determineIfSourceOrTarget(ResourceType resource) {
if (resource.getSchemaHandling() != null && CollectionUtils.isNotEmpty(resource.getSchemaHandling().getObjectType())) {
boolean hasOutbound = false;
boolean hasInbound = false;
for (ResourceObjectTypeDefinitionType resourceObjectTypeDefinition : resource.getSchemaHandling().getObjectType()) {
if (CollectionUtils.isEmpty(resourceObjectTypeDefinition.getAttribute())) {
continue;
}
if (hasInbound && hasOutbound) {
return SourceTarget.SOURCE_TARGET;
}
for (ResourceAttributeDefinitionType attr : resourceObjectTypeDefinition.getAttribute()) {
if (hasInbound && hasOutbound) {
return SourceTarget.SOURCE_TARGET;
}
if (!hasOutbound) {
hasOutbound = isOutboundDefined(attr);
}
if (!hasInbound) {
hasInbound = isInboundDefined(attr);
}
}
// TODO: what about situation that we have only
}
if (hasOutbound) {
return SourceTarget.TARGET;
}
if (hasInbound) {
return SourceTarget.SOURCE;
}
}
return SourceTarget.NOT_DEFINED;
}
Aggregations