use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project carbon-business-process by wso2.
the class TaskOperationsImpl method getRenderingTypes.
/**
* Applies to both tasks and notifications.
* Returns the rendering types available for the task or notification.
*
* @param taskIdURI : task identifier
* @return : Array of QNames
* @throws IllegalArgumentFault
*/
public QName[] getRenderingTypes(URI taskIdURI) throws IllegalArgumentFault {
try {
final Long taskId = validateTaskId(taskIdURI);
TaskDAO task = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<TaskDAO>() {
public TaskDAO call() throws Exception {
HumanTaskEngine engine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
HumanTaskDAOConnection daoConn = engine.getDaoConnectionFactory().getConnection();
TaskDAO task = daoConn.getTask(taskId);
validateTaskTenant(task);
return task;
}
});
HumanTaskBaseConfiguration taskConfiguration = HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(task.getTenantId()).getTaskConfiguration(QName.valueOf(task.getName()));
List<QName> renderingTypes = taskConfiguration.getRenderingTypes();
QName[] types = new QName[renderingTypes.size()];
types = renderingTypes.toArray(types);
return types;
} catch (Exception ex) {
log.error(ex);
throw new IllegalArgumentFault(ex);
}
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project carbon-apimgt by wso2.
the class GraphQLSchemaDefinition method extractGraphQLTypeList.
/**
* Extract GraphQL Types and Fields from given schema
*
* @param schema GraphQL Schema
* @return list of all types and fields
*/
public List<GraphqlSchemaType> extractGraphQLTypeList(String schema) {
List<GraphqlSchemaType> typeList = new ArrayList<>();
SchemaParser schemaParser = new SchemaParser();
TypeDefinitionRegistry typeRegistry = schemaParser.parse(schema);
Map<java.lang.String, TypeDefinition> list = typeRegistry.types();
for (Map.Entry<String, TypeDefinition> entry : list.entrySet()) {
if (entry.getValue() instanceof ObjectTypeDefinition) {
GraphqlSchemaType graphqlSchemaType = new GraphqlSchemaType();
List<String> fieldList = new ArrayList<>();
graphqlSchemaType.setType(entry.getValue().getName());
for (FieldDefinition fieldDef : ((ObjectTypeDefinition) entry.getValue()).getFieldDefinitions()) {
fieldList.add(fieldDef.getName());
}
graphqlSchemaType.setFieldList(fieldList);
typeList.add(graphqlSchemaType);
}
}
return typeList;
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project carbon-apimgt by wso2.
the class GraphqlQueryAnalysisMappingUtil method fromDTOtoValidatedGraphqlComplexityInfo.
/**
* Converts a GraphQLQueryComplexityInfo DTO object into a GraphqlComplexityInfo object. During this process a
* basic validation is done comparing with the types of the schema
*
* @param graphQLQueryComplexityInfoDTO GraphQLQueryComplexityInfoDTO object
* @param schema GraphQL Schema
* @return a new GraphqlComplexityInfo object corresponding to given GraphQLQueryComplexityInfoDTO object
*/
public static GraphqlComplexityInfo fromDTOtoValidatedGraphqlComplexityInfo(GraphQLQueryComplexityInfoDTO graphQLQueryComplexityInfoDTO, String schema) {
SchemaParser schemaParser = new SchemaParser();
Set<String> complexityInfoTypeSet = schemaParser.parse(schema).types().keySet();
GraphqlComplexityInfo graphqlComplexityInfo = new GraphqlComplexityInfo();
List<CustomComplexityDetails> customComplexityDetailsList = new ArrayList<CustomComplexityDetails>();
for (GraphQLCustomComplexityInfoDTO graphQLCustomComplexityInfoDTO : graphQLQueryComplexityInfoDTO.getList()) {
String complexityType = graphQLCustomComplexityInfoDTO.getType();
if (complexityInfoTypeSet.contains(complexityType)) {
CustomComplexityDetails customComplexityDetails = new CustomComplexityDetails();
customComplexityDetails.setType(complexityType);
customComplexityDetails.setField(graphQLCustomComplexityInfoDTO.getField());
customComplexityDetails.setComplexityValue(graphQLCustomComplexityInfoDTO.getComplexityValue());
customComplexityDetailsList.add(customComplexityDetails);
} else {
log.error("Complexity Type : " + complexityType + " is not included in the original schema. Hence " + "skipped.");
}
}
graphqlComplexityInfo.setList(customComplexityDetailsList);
return graphqlComplexityInfo;
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project carbon-apimgt by wso2.
the class RegistrationServiceImpl method createOAuthApp.
/**
* Method to create a OAuth App with client credentials
*
* @param appName application name
* @param grantTypes grant types
* @param userName username of the application
* @return created Oauth App
*/
private OAuthConsumerAppDTO createOAuthApp(String appName, OAuthApplicationInfo applicationInfo, String grantTypes, String userName) {
OAuthConsumerAppDTO createdApp = null;
OAuthAdminService oauthAdminService = new OAuthAdminService();
OAuthConsumerAppDTO oauthConsumerAppDTO = new OAuthConsumerAppDTO();
oauthConsumerAppDTO.setApplicationName(appName);
if (StringUtils.isNotBlank(applicationInfo.getCallBackURL())) {
oauthConsumerAppDTO.setCallbackUrl(applicationInfo.getCallBackURL());
}
oauthConsumerAppDTO.setUsername(userName);
oauthConsumerAppDTO.setOAuthVersion(OAuthConstants.OAuthVersions.VERSION_2);
oauthConsumerAppDTO.setGrantTypes(grantTypes.trim());
try {
boolean isHashDisabled = OAuth2Util.isHashDisabled();
if (isHashDisabled) {
// Creating the Oauth app
oauthAdminService.registerOAuthApplicationData(oauthConsumerAppDTO);
// Retrieving the created OAuth application
createdApp = oauthAdminService.getOAuthApplicationDataByAppName(oauthConsumerAppDTO.getApplicationName());
} else {
createdApp = oauthAdminService.registerAndRetrieveOAuthApplicationData(oauthConsumerAppDTO);
}
} catch (IdentityOAuthAdminException e) {
log.error("Error occurred while creating the OAuth app", e);
}
if (log.isDebugEnabled()) {
log.debug("Created OAuth App " + appName);
}
return createdApp;
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project carbon-apimgt by wso2.
the class AlertMgtUtils method toAlertTypeDTO.
/**
* Convert the alert types to alert type dtos.
*
* @param alertTypes: The alert types map.
* @return A list of AlertTypeDTOs.
*/
public static List<AlertTypeDTO> toAlertTypeDTO(Map<Integer, String> alertTypes) {
List<AlertTypeDTO> alertTypeDTOList = new ArrayList<>();
if (alertTypes != null) {
for (Map.Entry entry : alertTypes.entrySet()) {
AlertTypeDTO alertTypeDTO = new AlertTypeDTO();
alertTypeDTO.setId((Integer) entry.getKey());
alertTypeDTO.setName(entry.getValue().toString());
alertTypeDTOList.add(alertTypeDTO);
}
}
return alertTypeDTOList;
}
Aggregations