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;
}
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);
}
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);
}
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);
}
}
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;
}
Aggregations