Search in sources :

Example 1 with JasperReportParameterPropertiesDto

use of com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterPropertiesDto in project midpoint by Evolveum.

the class ParameterPropertiesPopupPanel method initLayout.

private void initLayout() {
    addTextPanel(ID_KEY, "key");
    addTextPanel(ID_LABEL, "label");
    addTextPanel(ID_TARGET_TYPE, "targetType");
    //	  CheckBoxPanel multivalue = new CheckBoxPanel(ID_MULTIVALUE, new PropertyModel<>(getModel(), "multivalue"), Model.of(Boolean.TRUE));
    //	  add(multivalue);
    AjaxButton update = new AjaxButton(ID_BUTTON_UPDATE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            getPageBase().hideMainPopup(target);
            IModel<JasperReportParameterPropertiesDto> model = ParameterPropertiesPopupPanel.this.getModel();
            updateProperties(model.getObject(), target);
        }
    };
    add(update);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) JasperReportParameterPropertiesDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterPropertiesDto)

Example 2 with JasperReportParameterPropertiesDto

use of com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterPropertiesDto in project midpoint by Evolveum.

the class RunReportPopupPanel method createLookupTableRows.

private <O extends ObjectType> List<LookupTableRowType> createLookupTableRows(JasperReportParameterDto param, String input) {
    ItemPath label = null;
    ItemPath key = null;
    List<LookupTableRowType> rows = new ArrayList<>();
    JasperReportParameterPropertiesDto properties = param.getProperties();
    if (properties == null) {
        return null;
    }
    String pLabel = properties.getLabel();
    if (pLabel != null) {
        label = new ItemPath(pLabel);
    }
    String pKey = properties.getKey();
    if (pKey != null) {
        key = new ItemPath(pKey);
    }
    String pTargetType = properties.getTargetType();
    Class<O> targetType = null;
    if (pTargetType != null) {
        try {
            targetType = (Class<O>) Class.forName(pTargetType);
        } catch (ClassNotFoundException e) {
            error("Error while creating lookup table for input parameter: " + param.getName() + ", " + e.getClass().getSimpleName() + " (" + e.getMessage() + ")");
        //e.printStackTrace();
        }
    }
    if (label != null && targetType != null && input != null) {
        OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
        Task task = createSimpleTask(OPERATION_LOAD_RESOURCES);
        Collection<PrismObject<O>> objects;
        ObjectQuery query = QueryBuilder.queryFor(targetType, getPrismContext()).item(new QName(SchemaConstants.NS_C, pLabel)).startsWith(input).matching(new QName(SchemaConstants.NS_MATCHING_RULE, "origIgnoreCase")).maxSize(AUTO_COMPLETE_BOX_SIZE).build();
        try {
            objects = getPageBase().getModelService().searchObjects(targetType, query, SelectorOptions.createCollection(GetOperationOptions.createNoFetch()), task, result);
            for (PrismObject<O> o : objects) {
                Object realKeyValue = null;
                PrismProperty labelItem = o.findProperty(label);
                //TODO: e.g. support not only for property, but also ref, container..
                if (labelItem == null || labelItem.isEmpty()) {
                    continue;
                }
                PrismProperty keyItem = o.findProperty(key);
                if ("oid".equals(pKey)) {
                    realKeyValue = o.getOid();
                }
                if (realKeyValue == null && (keyItem == null || keyItem.isEmpty())) {
                    continue;
                }
                //TODO: support for single/multivalue value 
                if (!labelItem.isSingleValue()) {
                    continue;
                }
                Object realLabelValue = labelItem.getRealValue();
                realKeyValue = (realKeyValue == null) ? keyItem.getRealValue() : realKeyValue;
                // TODO: take definition into account
                QName typeName = labelItem.getDefinition().getTypeName();
                LookupTableRowType row = new LookupTableRowType();
                if (realKeyValue != null) {
                    row.setKey(convertObjectToPolyStringType(realKeyValue).getOrig());
                } else {
                    throw new SchemaException("Cannot create lookup table with null key for label: " + realLabelValue);
                }
                row.setLabel(convertObjectToPolyStringType(realLabelValue));
                rows.add(row);
            }
            return rows;
        } catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
            error("Error while creating lookup table for input parameter: " + param.getName() + ", " + e.getClass().getSimpleName() + " (" + e.getMessage() + ")");
        //e.printStackTrace();
        }
    }
    return rows;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) JasperReportParameterPropertiesDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterPropertiesDto) PrismObject(com.evolveum.midpoint.prism.PrismObject) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) QName(javax.xml.namespace.QName) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PrismObject(com.evolveum.midpoint.prism.PrismObject) LookupTableRowType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

JasperReportParameterPropertiesDto (com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterPropertiesDto)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)1 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)1 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 LookupTableRowType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType)1 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1