private void readAction(XMLEventReader reader, StartElement element, CsdlSchema schema) throws XMLStreamException { CsdlAction action = new CsdlAction(); action.setParameters(new ArrayList<CsdlParameter>()); action.setName(attr(element, "Name")); action.setBound(Boolean.parseBoolean(attr(element, "IsBound"))); String entitySetPath = attr(element, "EntitySetPath"); if (entitySetPath != null) { // TODO: need to parse into binding and path. action.setEntitySetPath(entitySetPath); } readOperationParameters(reader, action); schema.getActions().add(action); }
@Override boolean isBound() throws ODataJPAModelException { return getEdmItem().isBound(); }
@Override public CsdlReturnType getReturnType() { return edmAction.getReturnType(); }
/** * Creates the ActionImports. Function Imports have to be created for <i>unbound</i> actions. These are actions, * which do not depend on an entity set. E.g. .../MyAction(). <p> * Details are described in : <a href= * "http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part3-csdl/odata-v4.0-errata02-os-part3-csdl- * complete.html#_Toc406398038">13.5 Element edm:ActionImport</a> * @param edmAc * @return */ private CsdlActionImport buildActionImport(CsdlAction edmAc) { final CsdlActionImport edmAcImport = new CsdlActionImport(); edmAcImport.setName(edmAc.getName()); edmAcImport.setAction(nameBuilder.buildFQN(edmAc.getName())); // edmAcImport.setEntitySet(entitySet) return edmAcImport; }
private void addActionImportAsProcedure(MetadataFactory mf, CsdlActionImport actionImport, ODataType odataType, XMLMetadata metadata) throws TranslatorException { List<CsdlAction> actions = getActions(metadata, actionImport.getAction()); for (CsdlAction action : actions) { if (!hasComplexParameters(action.getParameters())) { Procedure procedure = mf.addProcedure(action.getName()); addOperation(mf, metadata, odataType, action, procedure); } else { LogManager.logInfo(LogConstants.CTX_ODATA, ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17033, action.getName())); } } }
if (action.isBound()) { final List<CsdlParameter> parameters = action.getParameters(); final CsdlParameter parameter = parameters.get(0); if ((bindingParameterTypeName.equals(parameter.getTypeFQN()) ||
/** Adds annotations to actions * @param action * @param actionName * @param annotationGrp */ private void addAnnotationsToParamsOfActions(CsdlAction action, FullQualifiedName actionName, CsdlAnnotations annotationGrp) { final List<CsdlParameter> parameters = action.getParameters(); for (CsdlParameter parameter : parameters) { if (annotationGrp.getTarget().equalsIgnoreCase( actionName.getFullQualifiedNameAsString() + "/" + parameter.getName())) { for (CsdlAnnotation annotation : annotationGrp.getAnnotations()) { if (!compareAnnotations(action.getParameter(parameter.getName()).getAnnotations(), annotation)) { action.getParameter(parameter.getName()).getAnnotations().add(annotation); } } } } }
protected List<EdmAction> createActions() { final List<EdmAction> edmActions = new ArrayList<EdmAction>(); final List<CsdlAction> providerActions = schema.getActions(); if (providerActions != null) { for (CsdlAction action : providerActions) { FullQualifiedName actionName = new FullQualifiedName(namespace, action.getName()); EdmActionImpl edmActionImpl = new EdmActionImpl(edm, actionName, action); edmActions.add(edmActionImpl); edm.cacheAction(actionName, edmActionImpl); } } return edmActions; }
if (action.isBound()) { final List<CsdlParameter> parameters = action.getParameters(); final CsdlParameter parameter = parameters.get(0); if ((bindingParameterTypeName.equals(parameter.getTypeFQN()) ||
private void readAction(XMLEventReader reader, StartElement element, CsdlSchema schema) throws XMLStreamException { CsdlAction action = new CsdlAction(); action.setParameters(new ArrayList<CsdlParameter>()); action.setName(attr(element, "Name")); action.setBound(Boolean.parseBoolean(attr(element, "IsBound"))); String entitySetPath = attr(element, "EntitySetPath"); if (entitySetPath != null) { // TODO: need to parse into binding and path. action.setEntitySetPath(entitySetPath); } readOperationParameters(reader, action); schema.getActions().add(action); }
protected List<EdmAction> createActions() { final List<EdmAction> edmActions = new ArrayList<EdmAction>(); final List<CsdlAction> providerActions = schema.getActions(); if (providerActions != null) { for (CsdlAction action : providerActions) { FullQualifiedName actionName = new FullQualifiedName(namespace, action.getName()); EdmActionImpl edmActionImpl = new EdmActionImpl(edm, actionName, action); edmActions.add(edmActionImpl); edm.cacheAction(actionName, edmActionImpl); } } return edmActions; }
@Override protected EdmAction createUnboundAction(final FullQualifiedName actionName) { try { List<CsdlAction> actions = actionsMap.get(actionName); if (actions == null) { actions = provider.getActions(actionName); if (actions == null) { return null; } else { actionsMap.put(actionName, actions); } } // Search for first unbound action for (CsdlAction action : actions) { if (!action.isBound()) { return new EdmActionImpl(this, actionName, action); } } return null; } catch (ODataException e) { throw new EdmException(e); } }
private String setEntitySetPath() throws ODataJPAModelException { if (jpaAction.entitySetPath() == null || jpaAction.entitySetPath().isEmpty()) return null; if (!jpaAction.isBound()) // Entity Set Path shall only provided for bound actions. Action method %1$s of class %2$s is unbound. throw new ODataJPAModelException(ODataJPAModelException.MessageKeys.ACTION_UNBOUND_ENTITY_SET, javaAction.getName(), javaAction.getDeclaringClass().getName()); if (!edmAction.getReturnType().isCollection() && schema.getEntityType(javaAction.getReturnType()) == null) throw new ODataJPAModelException(ODataJPAModelException.MessageKeys.ACTION_UNBOUND_ENTITY_SET, javaAction.getName(), javaAction.getDeclaringClass().getName()); return jpaAction.entitySetPath(); }
@Override protected void lazyBuildEdmItem() throws ODataJPAModelException { if (edmAction == null) { edmAction = new CsdlAction(); // edmAction.setAnnotations(annotations); edmAction.setBound(jpaAction.isBound()); edmAction.setName(getExternalName()); edmAction.setParameters(returnNullIfEmpty(determineEdmInputParameter())); edmAction.setReturnType(determineEdmResultType(jpaAction.returnType(), javaAction)); edmAction.setEntitySetPath(setEntitySetPath()); } }
@Override public List<CsdlAction> getActions(final FullQualifiedName fqn) throws ODataException { ArrayList<CsdlAction> actions = new ArrayList<CsdlAction>(); CsdlSchema schema = getSchema(fqn.getNamespace()); if (schema != null) { List<CsdlAction> types = schema.getActions(); if (types != null) { for (CsdlAction type : types) { if (type.getName().equals(fqn.getName())) { actions.add(type); } } } } return actions; }
@Override protected EdmAction createUnboundAction(final FullQualifiedName actionName) { try { List<CsdlAction> actions = actionsMap.get(actionName); if (actions == null) { actions = provider.getActions(actionName); if (actions == null) { return null; } else { actionsMap.put(actionName, actions); } } // Search for first unbound action for (CsdlAction action : actions) { if (!action.isBound()) { return new EdmActionImpl(this, actionName, action); } } return null; } catch (ODataException e) { throw new EdmException(e); } }
public static CommonJavaObjectForEdmx convertFromActionsNfunctions(CommonJavaObjectForEdmx comModel, CDXEdmProvider edmxProvider, Map<String, String> namespaceToServMap) { CommonJavaObjectForEdmx updatedComModel = comModel; try { List<CsdlAction> actions = edmxProvider.getSchemas().get(0).getActions(); for (CsdlAction action : actions) { if (action.getReturnType() != null && !action.getReturnType().getType().startsWith("Edm")) { FullQualifiedName fqn = action.getReturnType().getTypeFQN(); updatedComModel = addCsdlComplexOrEntityToComModel(comModel, edmxProvider, fqn, namespaceToServMap); } } List<CsdlFunction> functions = edmxProvider.getSchemas().get(0).getFunctions(); for (CsdlFunction function : functions) { if (function.getReturnType() != null && function.getReturnType().getType().startsWith("Edm")) { FullQualifiedName fqn = function.getReturnType().getTypeFQN(); updatedComModel = addCsdlComplexOrEntityToComModel(updatedComModel, edmxProvider, fqn, namespaceToServMap); } } } catch (ODataException e) { PojoGenUtil.logDebug(log, "Could not parse Action/Function return type"); } return updatedComModel; }
ArrayList<CsdlAction> actions, ArrayList<CsdlActionImport> actionImports, CsdlSchema csdlSchema) { CsdlAction edmAction = new CsdlAction(); edmAction.setName(proc.getName()); edmAction.setBound(false); EdmPrimitiveTypeKind odatatype = ODataTypeManager.odataType(pp); if (pp.getType().equals(ProcedureParameter.Type.ReturnValue)) { edmAction.setReturnType(new CsdlReturnType().setType(odatatype.getFullQualifiedName()).setCollection(DataTypeManager.isArrayType(pp.getRuntimeType()))); continue; edmAction.setParameters(params); CsdlComplexType complexType = buildComplexType(proc, returnColumns, csdlSchema); complexTypes.add(complexType); edmAction.setReturnType((new CsdlReturnType() .setType(new FullQualifiedName(schemaName, complexType .getName())).setCollection(true)));
@Override public List<CsdlAction> getActions(final FullQualifiedName fqn) throws ODataException { ArrayList<CsdlAction> actions = new ArrayList<CsdlAction>(); CsdlSchema schema = getSchema(fqn.getNamespace()); if (schema != null) { List<CsdlAction> types = schema.getActions(); if (types != null) { for (CsdlAction type : types) { if (type.getName().equals(fqn.getName())) { actions.add(type); } } } } return actions; }
try { boundActionStream = metadataInfo.getEdmxMetadataProvider().getSchemas().stream().flatMap(schema-> schema.getActions().stream()).filter(action->action.isBound()); } catch (Exception e) { boundActionStream = Stream.empty();