Search in sources :

Example 11 with PrismContainer

use of com.evolveum.midpoint.prism.PrismContainer in project midpoint by Evolveum.

the class MidPointAbstractDataSource method getFieldValue.

@Override
public Object getFieldValue(JRField jrField) throws JRException {
    // TODO Auto-generated method stub
    String fieldName = jrField.getName();
    if (fieldName.equals("oid")) {
        return currentObject.getOid();
    }
    Item i = currentObject.findItem(new QName(fieldName));
    if (i == null) {
        return null;
    }
    if (i instanceof PrismProperty) {
        if (i.isSingleValue()) {
            return ((PrismProperty) i).getRealValue();
        }
        return ((PrismProperty) i).getRealValues();
    } else if (i instanceof PrismReference) {
        if (i.isSingleValue()) {
            return ((PrismReference) i).getValue().asReferencable();
        }
        List<Referencable> refs = new ArrayList<Referencable>();
        for (PrismReferenceValue refVal : ((PrismReference) i).getValues()) {
            refs.add(refVal.asReferencable());
        }
        return refs;
    } else if (i instanceof PrismContainer) {
        if (i.isSingleValue()) {
            return ((PrismContainer) i).getValue().asContainerable();
        }
        List<Containerable> containers = new ArrayList<Containerable>();
        for (Object pcv : i.getValues()) {
            if (pcv instanceof PrismContainerValue) {
                containers.add(((PrismContainerValue) pcv).asContainerable());
            }
        }
        return containers;
    } else
        throw new JRException("Could not get value of the fileld: " + fieldName);
}
Also used : Referencable(com.evolveum.midpoint.prism.Referencable) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) JRException(net.sf.jasperreports.engine.JRException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Item(com.evolveum.midpoint.prism.Item) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PrismReference(com.evolveum.midpoint.prism.PrismReference) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) ArrayList(java.util.ArrayList) List(java.util.List) Containerable(com.evolveum.midpoint.prism.Containerable) PrismObject(com.evolveum.midpoint.prism.PrismObject)

Example 12 with PrismContainer

use of com.evolveum.midpoint.prism.PrismContainer in project midpoint by Evolveum.

the class ReportOperationalButtonsPanel method runReportPerformed.

public static void runReportPerformed(AjaxRequestTarget target, PrismObject<ReportType> report, PageBase pageBase) {
    if (!hasParameters(report.asObjectable())) {
        runConfirmPerformed(target, report, null, pageBase);
        return;
    }
    RunReportPopupPanel runReportPopupPanel = new RunReportPopupPanel(pageBase.getMainPopupBodyId(), report.asObjectable()) {

        private static final long serialVersionUID = 1L;

        protected void runConfirmPerformed(AjaxRequestTarget target, PrismObject<ReportType> report, PrismContainer<ReportParameterType> reportParam) {
            ReportOperationalButtonsPanel.runConfirmPerformed(target, report, reportParam, pageBase);
            pageBase.hideMainPopup(target);
        }
    };
    pageBase.showMainPopup(runReportPopupPanel, target);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) RunReportPopupPanel(com.evolveum.midpoint.web.page.admin.reports.component.RunReportPopupPanel)

Example 13 with PrismContainer

use of com.evolveum.midpoint.prism.PrismContainer in project midpoint by Evolveum.

the class SchemaStep method createXmlEditorModel.

private IModel<String> createXmlEditorModel() {
    return new IModel<String>() {

        @Override
        public void detach() {
        }

        @Override
        public String getObject() {
            PrismObject<ResourceType> resource = model.getObject();
            PrismContainer xmlSchema = resource.findContainer(ResourceType.F_SCHEMA);
            if (xmlSchema == null) {
                return null;
            }
            PageBase page = (PageBase) SchemaStep.this.getPage();
            try {
                return page.getPrismContext().xmlSerializer().serialize(xmlSchema.getValue(), SchemaConstantsGenerated.C_SCHEMA);
            } catch (SchemaException | RuntimeException ex) {
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't serialize resource schema", ex);
                return WebComponentUtil.exceptionToString("Couldn't serialize resource schema", ex);
            }
        }

        @Override
        public void setObject(String object) {
        // ignore (it's interesting that this is called sometimes, even when the ACE is set to be read only)
        }
    };
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IModel(org.apache.wicket.model.IModel) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Example 14 with PrismContainer

use of com.evolveum.midpoint.prism.PrismContainer in project midpoint by Evolveum.

the class ConnIdConfigurationTransformer method transformConnectorConfiguration.

/**
 * Transforms midPoint XML configuration of the connector to the ICF
 * configuration.
 * <p/>
 * The "configuration" part of the XML resource definition will be used.
 * <p/>
 * The provided ICF APIConfiguration will be modified, some values may be
 * overwritten.
 *
 * @throws SchemaException
 * @throws ConfigurationException
 */
public APIConfiguration transformConnectorConfiguration(PrismContainerValue configuration) throws SchemaException, ConfigurationException {
    APIConfiguration apiConfig = cinfo.createDefaultAPIConfiguration();
    ConfigurationProperties configProps = apiConfig.getConfigurationProperties();
    // The namespace of all the configuration properties specific to the
    // connector instance will have a connector instance namespace. This
    // namespace can be found in the resource definition.
    String connectorConfNs = connectorType.getNamespace();
    PrismContainer configurationPropertiesContainer = configuration.findContainer(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME);
    if (configurationPropertiesContainer == null) {
        // Also try this. This is an older way.
        configurationPropertiesContainer = configuration.findContainer(new QName(connectorConfNs, SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_LOCAL_NAME));
    }
    transformConnectorConfigurationProperties(configProps, configurationPropertiesContainer, connectorConfNs);
    PrismContainer connectorPoolContainer = configuration.findContainer(new QName(SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_XML_ELEMENT_NAME));
    ObjectPoolConfiguration connectorPoolConfiguration = apiConfig.getConnectorPoolConfiguration();
    transformConnectorPoolConfiguration(connectorPoolConfiguration, connectorPoolContainer);
    PrismProperty producerBufferSizeProperty = configuration.findProperty(new ItemName(SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_PRODUCER_BUFFER_SIZE_XML_ELEMENT_NAME));
    if (producerBufferSizeProperty != null) {
        apiConfig.setProducerBufferSize(parseInt(producerBufferSizeProperty));
    }
    PrismContainer connectorTimeoutsContainer = configuration.findContainer(new QName(SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_TIMEOUTS_XML_ELEMENT_NAME));
    transformConnectorTimeoutsConfiguration(apiConfig, connectorTimeoutsContainer);
    PrismContainer resultsHandlerConfigurationContainer = configuration.findContainer(new QName(SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ELEMENT_LOCAL_NAME));
    ResultsHandlerConfiguration resultsHandlerConfiguration = apiConfig.getResultsHandlerConfiguration();
    transformResultsHandlerConfiguration(resultsHandlerConfiguration, resultsHandlerConfigurationContainer);
    return apiConfig;
}
Also used : PrismProperty(com.evolveum.midpoint.prism.PrismProperty) ObjectPoolConfiguration(org.identityconnectors.common.pooling.ObjectPoolConfiguration) ResultsHandlerConfiguration(org.identityconnectors.framework.api.ResultsHandlerConfiguration) QName(javax.xml.namespace.QName) APIConfiguration(org.identityconnectors.framework.api.APIConfiguration) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) ItemName(com.evolveum.midpoint.prism.path.ItemName) ConfigurationProperties(org.identityconnectors.framework.api.ConfigurationProperties) GuardedString(org.identityconnectors.common.security.GuardedString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 15 with PrismContainer

use of com.evolveum.midpoint.prism.PrismContainer in project midpoint by Evolveum.

the class QOperationExecutionMapping method createRowTransformer.

@Override
public ResultListRowTransformer<OperationExecutionType, QOperationExecution<OR>, MOperationExecution> createRowTransformer(SqlQueryContext<OperationExecutionType, QOperationExecution<OR>, MOperationExecution> sqlQueryContext, JdbcSession jdbcSession) {
    Map<UUID, ObjectType> owners = new HashMap<>();
    return new ResultListRowTransformer<>() {

        @Override
        public void beforeTransformation(List<Tuple> rowTuples, QOperationExecution<OR> entityPath) throws SchemaException {
            Set<UUID> ownerOids = rowTuples.stream().map(row -> Objects.requireNonNull(row.get(entityPath)).ownerOid).collect(Collectors.toSet());
            // TODO do we need get options here as well? Is there a scenario where we load container
            // and define what to load for referenced/owner object?
            QObject<?> o = QObjectMapping.getObjectMapping().defaultAlias();
            List<Tuple> result = jdbcSession.newQuery().select(o.oid, o.fullObject).from(o).where(o.oid.in(ownerOids)).fetch();
            for (Tuple row : result) {
                UUID oid = Objects.requireNonNull(row.get(o.oid));
                ObjectType owner = parseSchemaObject(row.get(o.fullObject), oid.toString(), ObjectType.class);
                owners.put(oid, owner);
            }
        }

        @Override
        public OperationExecutionType transform(Tuple rowTuple, QOperationExecution<OR> entityPath, Collection<SelectorOptions<GetOperationOptions>> options) {
            MOperationExecution row = Objects.requireNonNull(rowTuple.get(entityPath));
            ObjectType object = Objects.requireNonNull(owners.get(row.ownerOid), () -> "Missing owner with OID " + row.ownerOid + " for OperationExecution with ID " + row.cid);
            PrismContainer<OperationExecutionType> opexContainer = object.asPrismObject().findContainer(ObjectType.F_OPERATION_EXECUTION);
            if (opexContainer == null) {
                throw new SystemException("Object " + object + " has no operation execution as expected from " + row);
            }
            PrismContainerValue<OperationExecutionType> pcv = opexContainer.findValue(row.cid);
            if (pcv == null) {
                throw new SystemException("Object " + object + " has no operation execution with ID " + row.cid);
            }
            return pcv.asContainerable();
        }
    };
}
Also used : SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) TableRelationResolver(com.evolveum.midpoint.repo.sqlbase.mapping.TableRelationResolver) java.util(java.util) SqlQueryContext(com.evolveum.midpoint.repo.sqlbase.SqlQueryContext) QTaskMapping(com.evolveum.midpoint.repo.sqale.qmodel.task.QTaskMapping) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) QContainerMapping(com.evolveum.midpoint.repo.sqale.qmodel.common.QContainerMapping) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) MiscUtil(com.evolveum.midpoint.util.MiscUtil) SqaleRepoContext(com.evolveum.midpoint.repo.sqale.SqaleRepoContext) QFocusMapping(com.evolveum.midpoint.repo.sqale.qmodel.focus.QFocusMapping) Collectors(java.util.stream.Collectors) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) OperationExecutionType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationExecutionType) SystemException(com.evolveum.midpoint.util.exception.SystemException) PrismConstants(com.evolveum.midpoint.prism.PrismConstants) ResultListRowTransformer(com.evolveum.midpoint.repo.sqlbase.mapping.ResultListRowTransformer) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) NotNull(org.jetbrains.annotations.NotNull) Tuple(com.querydsl.core.Tuple) ResultListRowTransformer(com.evolveum.midpoint.repo.sqlbase.mapping.ResultListRowTransformer) OperationExecutionType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationExecutionType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) SystemException(com.evolveum.midpoint.util.exception.SystemException) Tuple(com.querydsl.core.Tuple)

Aggregations

PrismContainer (com.evolveum.midpoint.prism.PrismContainer)28 PrismObject (com.evolveum.midpoint.prism.PrismObject)12 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)9 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)6 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)5 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 RunReportPopupPanel (com.evolveum.midpoint.web.page.admin.reports.component.RunReportPopupPanel)5 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)5 Item (com.evolveum.midpoint.prism.Item)4 PrismReference (com.evolveum.midpoint.prism.PrismReference)4 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)4 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 ArrayList (java.util.ArrayList)4 Task (com.evolveum.midpoint.task.api.Task)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 Containerable (com.evolveum.midpoint.prism.Containerable)2 PrismContext (com.evolveum.midpoint.prism.PrismContext)2 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)2 PrismValue (com.evolveum.midpoint.prism.PrismValue)2 Referencable (com.evolveum.midpoint.prism.Referencable)2