Search in sources :

Example 1 with ParameterMetaData

use of org.wso2.carbon.identity.workflow.mgt.bean.metadata.ParameterMetaData in project carbon-identity-framework by wso2.

the class AbstractTemplate method getParametersMetaData.

/**
 * Retrieve template specific metadata
 *
 * @return ParametersMetaData object that is contain all the template specific parameter metadata.
 */
public ParametersMetaData getParametersMetaData() throws WorkflowException {
    if (parametersMetaData != null) {
        ParameterMetaData[] parameterMetaData = parametersMetaData.getParameterMetaData();
        for (ParameterMetaData metaData : parameterMetaData) {
            if (metaData.isIsInputDataRequired()) {
                InputData inputData = getInputData(metaData.getName());
                metaData.setInputData(inputData);
            }
        }
    }
    return parametersMetaData;
}
Also used : InputData(org.wso2.carbon.identity.workflow.mgt.bean.metadata.InputData) ParameterMetaData(org.wso2.carbon.identity.workflow.mgt.bean.metadata.ParameterMetaData)

Example 2 with ParameterMetaData

use of org.wso2.carbon.identity.workflow.mgt.bean.metadata.ParameterMetaData in project carbon-identity-framework by wso2.

the class WorkflowUIUtil method loadWorkflowImplParameters.

/**
 * Load implementaions related parameters of a workflow
 *
 * @param requestParameterMap parameter map
 * @param workflowWizard      Workflow object
 */
public static void loadWorkflowImplParameters(Map<String, String[]> requestParameterMap, WorkflowWizard workflowWizard) {
    Parameter[] workflowImplParameters = workflowWizard.getWorkflowImplParameters();
    Map<String, Parameter> workflowImplParameterMap = new HashMap<>();
    if (workflowImplParameters != null) {
        for (Parameter param : workflowImplParameters) {
            workflowImplParameterMap.put(param.getQName(), param);
        }
    }
    WorkflowImpl workflowImpl = workflowWizard.getWorkflowImpl();
    if (workflowImpl != null) {
        ParametersMetaData parametersMetaData = workflowImpl.getParametersMetaData();
        if (parametersMetaData != null && parametersMetaData.getParameterMetaData() != null) {
            ParameterMetaData[] parameterMetaData = parametersMetaData.getParameterMetaData();
            for (ParameterMetaData metaData : parameterMetaData) {
                if (requestParameterMap.get(metaData.getName()) != null) {
                    Parameter parameter = workflowImplParameterMap.get(metaData.getName());
                    String value = requestParameterMap.get(metaData.getName())[0];
                    if (parameter == null) {
                        parameter = new Parameter();
                        parameter.setParamName(metaData.getName());
                        parameter.setHolder(WorkflowUIConstants.ParameterHolder.WORKFLOW_IMPL);
                        workflowImplParameterMap.put(parameter.getParamName(), parameter);
                    }
                    parameter.setParamValue(value);
                    parameter.setQName(metaData.getName());
                } else {
                    for (Map.Entry<String, String[]> entry : requestParameterMap.entrySet()) {
                        if (entry != null && entry.getKey().startsWith(metaData.getName())) {
                            Parameter parameter = workflowImplParameterMap.get(entry.getKey());
                            if (parameter == null) {
                                parameter = new Parameter();
                                parameter.setParamName(metaData.getName());
                                parameter.setHolder(WorkflowUIConstants.ParameterHolder.WORKFLOW_IMPL);
                                parameter.setQName(entry.getKey());
                                workflowImplParameterMap.put(entry.getKey(), parameter);
                            }
                            String[] values = requestParameterMap.get(entry.getKey());
                            if (values != null && values.length > 0) {
                                String aValue = values[0];
                                parameter.setParamValue(aValue);
                            }
                        }
                    }
                }
            }
        }
    }
    Collection<Parameter> values = workflowImplParameterMap.values();
    Parameter[] parameters = values.toArray(new Parameter[values.size()]);
    workflowWizard.setWorkflowImplParameters(parameters);
}
Also used : HashMap(java.util.HashMap) ParametersMetaData(org.wso2.carbon.identity.workflow.mgt.stub.metadata.bean.ParametersMetaData) WorkflowImpl(org.wso2.carbon.identity.workflow.mgt.stub.metadata.WorkflowImpl) Parameter(org.wso2.carbon.identity.workflow.mgt.stub.bean.Parameter) Map(java.util.Map) HashMap(java.util.HashMap) ParameterMetaData(org.wso2.carbon.identity.workflow.mgt.stub.metadata.bean.ParameterMetaData)

Example 3 with ParameterMetaData

use of org.wso2.carbon.identity.workflow.mgt.bean.metadata.ParameterMetaData in project carbon-identity-framework by wso2.

the class WorkflowUIUtil method loadTemplateParameters.

/**
 * Load parameters of a workflow template
 *
 * @param requestParameterMap parameter map
 * @param workflowWizard      Workflow object
 */
public static void loadTemplateParameters(Map<String, String[]> requestParameterMap, WorkflowWizard workflowWizard) {
    Map<String, Parameter> templateParameterMap = new HashMap<>();
    Template template = workflowWizard.getTemplate();
    if (template != null) {
        ParametersMetaData parametersMetaData = template.getParametersMetaData();
        if (parametersMetaData != null && parametersMetaData.getParameterMetaData() != null) {
            ParameterMetaData[] parameterMetaData = parametersMetaData.getParameterMetaData();
            for (ParameterMetaData metaData : parameterMetaData) {
                if (requestParameterMap.get(metaData.getName()) != null) {
                    String value = requestParameterMap.get(metaData.getName())[0];
                    Parameter parameter = new Parameter();
                    parameter.setParamName(metaData.getName());
                    parameter.setHolder(WorkflowUIConstants.ParameterHolder.TEMPLATE);
                    templateParameterMap.put(parameter.getParamName(), parameter);
                    parameter.setParamValue(value);
                    parameter.setQName(metaData.getName());
                } else {
                    for (Map.Entry<String, String[]> entry : requestParameterMap.entrySet()) {
                        if (entry != null && entry.getKey().startsWith(metaData.getName())) {
                            Parameter parameter = new Parameter();
                            parameter.setParamName(metaData.getName());
                            parameter.setHolder(WorkflowUIConstants.ParameterHolder.TEMPLATE);
                            parameter.setQName(entry.getKey());
                            templateParameterMap.put(entry.getKey(), parameter);
                            String[] values = entry.getValue();
                            if (values != null && values.length > 0) {
                                String aValue = values[0];
                                parameter.setParamValue(aValue);
                            }
                        }
                    }
                }
            }
        }
    }
    Collection<Parameter> values = templateParameterMap.values();
    Parameter[] parameters = values.toArray(new Parameter[values.size()]);
    workflowWizard.setTemplateParameters(parameters);
}
Also used : HashMap(java.util.HashMap) ParametersMetaData(org.wso2.carbon.identity.workflow.mgt.stub.metadata.bean.ParametersMetaData) Template(org.wso2.carbon.identity.workflow.mgt.stub.metadata.Template) Parameter(org.wso2.carbon.identity.workflow.mgt.stub.bean.Parameter) Map(java.util.Map) HashMap(java.util.HashMap) ParameterMetaData(org.wso2.carbon.identity.workflow.mgt.stub.metadata.bean.ParameterMetaData)

Example 4 with ParameterMetaData

use of org.wso2.carbon.identity.workflow.mgt.bean.metadata.ParameterMetaData in project siddhi by wso2.

the class DocumentationUtils method addExtensionMetaDataIntoNamespaceList.

/**
 * Generate extension meta data from the annotated data in the class
 *
 * @param namespaceList  The list of namespaces to which the new extension will be added
 * @param extensionClass Class from which meta data should be extracted from
 * @param logger         The maven plugin logger
 */
private static void addExtensionMetaDataIntoNamespaceList(List<NamespaceMetaData> namespaceList, Class<?> extensionClass, Log logger) {
    Extension extensionAnnotation = extensionClass.getAnnotation(Extension.class);
    if (extensionAnnotation != null) {
        // Discarding extension classes without annotation
        ExtensionMetaData extensionMetaData = new ExtensionMetaData();
        // Finding extension type
        String extensionType = null;
        for (Map.Entry<ExtensionType, Class<?>> entry : ExtensionType.getSuperClassMap().entrySet()) {
            Class<?> superClass = entry.getValue();
            if (superClass.isAssignableFrom(extensionClass) && superClass != extensionClass) {
                extensionType = entry.getKey().getValue();
                break;
            }
        }
        // Discarding the extension if it belongs to an unknown type
        if (extensionType == null) {
            logger.warn("Discarding extension (belonging to an unknown extension type): " + extensionClass.getCanonicalName());
            return;
        }
        extensionMetaData.setName(extensionAnnotation.name());
        extensionMetaData.setDescription(extensionAnnotation.description());
        // Adding query parameters
        ParameterMetaData[] parameters = new ParameterMetaData[extensionAnnotation.parameters().length];
        for (int i = 0; i < extensionAnnotation.parameters().length; i++) {
            Parameter parameterAnnotation = extensionAnnotation.parameters()[i];
            ParameterMetaData parameter = new ParameterMetaData();
            parameter.setName(parameterAnnotation.name());
            parameter.setType(Arrays.asList(parameterAnnotation.type()));
            parameter.setDescription(parameterAnnotation.description());
            parameter.setOptional(parameterAnnotation.optional());
            parameter.setDynamic(parameterAnnotation.dynamic());
            parameter.setDefaultValue(parameterAnnotation.defaultValue());
            parameters[i] = parameter;
        }
        extensionMetaData.setParameters(Arrays.asList(parameters));
        // Adding system parameters
        SystemParameterMetaData[] systemParameters = new SystemParameterMetaData[extensionAnnotation.systemParameter().length];
        for (int i = 0; i < extensionAnnotation.systemParameter().length; i++) {
            SystemParameter systemParameterAnnotation = extensionAnnotation.systemParameter()[i];
            SystemParameterMetaData systemParameter = new SystemParameterMetaData();
            systemParameter.setName(systemParameterAnnotation.name());
            systemParameter.setDescription(systemParameterAnnotation.description());
            systemParameter.setDefaultValue(systemParameterAnnotation.defaultValue());
            systemParameter.setPossibleParameters(Arrays.asList(systemParameterAnnotation.possibleParameters()));
            systemParameters[i] = systemParameter;
        }
        extensionMetaData.setSystemParameters(Arrays.asList(systemParameters));
        // Adding return attributes
        ReturnAttributeMetaData[] returnAttributes = new ReturnAttributeMetaData[extensionAnnotation.returnAttributes().length];
        for (int i = 0; i < extensionAnnotation.returnAttributes().length; i++) {
            ReturnAttribute parameterAnnotation = extensionAnnotation.returnAttributes()[i];
            ReturnAttributeMetaData returnAttribute = new ReturnAttributeMetaData();
            returnAttribute.setName(parameterAnnotation.name());
            returnAttribute.setType(Arrays.asList(parameterAnnotation.type()));
            returnAttribute.setDescription(parameterAnnotation.description());
            returnAttributes[i] = returnAttribute;
        }
        extensionMetaData.setReturnAttributes(Arrays.asList(returnAttributes));
        // Adding examples
        ExampleMetaData[] examples = new ExampleMetaData[extensionAnnotation.examples().length];
        for (int i = 0; i < extensionAnnotation.examples().length; i++) {
            Example exampleAnnotation = extensionAnnotation.examples()[i];
            ExampleMetaData exampleMetaData = new ExampleMetaData();
            exampleMetaData.setSyntax(exampleAnnotation.syntax());
            exampleMetaData.setDescription(exampleAnnotation.description());
            examples[i] = exampleMetaData;
        }
        extensionMetaData.setExamples(Arrays.asList(examples));
        // Finding the namespace
        String namespaceName = extensionAnnotation.namespace();
        if (Objects.equals(namespaceName, "")) {
            namespaceName = Constants.CORE_NAMESPACE;
        }
        // Finding the relevant namespace in the namespace list
        NamespaceMetaData namespace = null;
        for (NamespaceMetaData existingNamespace : namespaceList) {
            if (Objects.equals(existingNamespace.getName(), namespaceName)) {
                namespace = existingNamespace;
                break;
            }
        }
        // Creating namespace if it doesn't exist
        if (namespace == null) {
            namespace = new NamespaceMetaData();
            namespace.setName(namespaceName);
            namespace.setExtensionMap(new TreeMap<>());
            namespaceList.add(namespace);
        }
        // Adding to the relevant extension metadata list in the namespace
        List<ExtensionMetaData> extensionMetaDataList = namespace.getExtensionMap().computeIfAbsent(extensionType, k -> new ArrayList<>());
        extensionMetaDataList.add(extensionMetaData);
    }
}
Also used : ReturnAttribute(org.wso2.siddhi.annotation.ReturnAttribute) Example(org.wso2.siddhi.annotation.Example) SystemParameter(org.wso2.siddhi.annotation.SystemParameter) ExampleMetaData(org.wso2.siddhi.doc.gen.commons.metadata.ExampleMetaData) NamespaceMetaData(org.wso2.siddhi.doc.gen.commons.metadata.NamespaceMetaData) Extension(org.wso2.siddhi.annotation.Extension) ReturnAttributeMetaData(org.wso2.siddhi.doc.gen.commons.metadata.ReturnAttributeMetaData) ExtensionType(org.wso2.siddhi.doc.gen.commons.metadata.ExtensionType) ExtensionMetaData(org.wso2.siddhi.doc.gen.commons.metadata.ExtensionMetaData) SystemParameterMetaData(org.wso2.siddhi.doc.gen.commons.metadata.SystemParameterMetaData) SystemParameter(org.wso2.siddhi.annotation.SystemParameter) Parameter(org.wso2.siddhi.annotation.Parameter) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) ParameterMetaData(org.wso2.siddhi.doc.gen.commons.metadata.ParameterMetaData) SystemParameterMetaData(org.wso2.siddhi.doc.gen.commons.metadata.SystemParameterMetaData)

Example 5 with ParameterMetaData

use of org.wso2.carbon.identity.workflow.mgt.bean.metadata.ParameterMetaData in project carbon-identity-framework by wso2.

the class AbstractWorkflow method getParametersMetaData.

/**
 * Can be retrieve workflow implementation specific meta data
 *
 * @return
 * @throws WorkflowException
 */
public ParametersMetaData getParametersMetaData() throws WorkflowException {
    if (parametersMetaData != null) {
        ParameterMetaData[] parameterMetaData = parametersMetaData.getParameterMetaData();
        for (ParameterMetaData metaData : parameterMetaData) {
            if (metaData.isIsInputDataRequired()) {
                InputData inputData = getInputData(metaData);
                metaData.setInputData(inputData);
            }
        }
    }
    return parametersMetaData;
}
Also used : InputData(org.wso2.carbon.identity.workflow.mgt.bean.metadata.InputData) ParameterMetaData(org.wso2.carbon.identity.workflow.mgt.bean.metadata.ParameterMetaData)

Aggregations

HashMap (java.util.HashMap)3 Map (java.util.Map)3 InputData (org.wso2.carbon.identity.workflow.mgt.bean.metadata.InputData)2 ParameterMetaData (org.wso2.carbon.identity.workflow.mgt.bean.metadata.ParameterMetaData)2 Parameter (org.wso2.carbon.identity.workflow.mgt.stub.bean.Parameter)2 ParameterMetaData (org.wso2.carbon.identity.workflow.mgt.stub.metadata.bean.ParameterMetaData)2 ParametersMetaData (org.wso2.carbon.identity.workflow.mgt.stub.metadata.bean.ParametersMetaData)2 TreeMap (java.util.TreeMap)1 Template (org.wso2.carbon.identity.workflow.mgt.stub.metadata.Template)1 WorkflowImpl (org.wso2.carbon.identity.workflow.mgt.stub.metadata.WorkflowImpl)1 Example (org.wso2.siddhi.annotation.Example)1 Extension (org.wso2.siddhi.annotation.Extension)1 Parameter (org.wso2.siddhi.annotation.Parameter)1 ReturnAttribute (org.wso2.siddhi.annotation.ReturnAttribute)1 SystemParameter (org.wso2.siddhi.annotation.SystemParameter)1 ExampleMetaData (org.wso2.siddhi.doc.gen.commons.metadata.ExampleMetaData)1 ExtensionMetaData (org.wso2.siddhi.doc.gen.commons.metadata.ExtensionMetaData)1 ExtensionType (org.wso2.siddhi.doc.gen.commons.metadata.ExtensionType)1 NamespaceMetaData (org.wso2.siddhi.doc.gen.commons.metadata.NamespaceMetaData)1 ParameterMetaData (org.wso2.siddhi.doc.gen.commons.metadata.ParameterMetaData)1