Java Code Examples for org.apache.olingo.commons.api.edm.provider.CsdlSchema#setActions()

The following examples show how to use org.apache.olingo.commons.api.edm.provider.CsdlSchema#setActions() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DemoEdmProvider.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
@Override
public List<CsdlSchema> getSchemas() {
  // create Schema
  CsdlSchema schema = new CsdlSchema();
  schema.setNamespace(NAMESPACE);

  // add EntityTypes
  List<CsdlEntityType> entityTypes = new ArrayList<CsdlEntityType>();
  entityTypes.add(getEntityType(ET_PRODUCT_FQN));
  entityTypes.add(getEntityType(ET_CATEGORY_FQN));
  entityTypes.add(getEntityType(ET_ADVERTISEMENT_FQN));
  schema.setEntityTypes(entityTypes);
  
  // add actions
  List<CsdlAction> actions = new ArrayList<CsdlAction>();
  actions.addAll(getActions(ACTION_RESET_FQN));
  schema.setActions(actions);
  
  // add functions
  List<CsdlFunction> functions = new ArrayList<CsdlFunction>();
  functions.addAll(getFunctions(FUNCTION_COUNT_CATEGORIES_FQN));
  schema.setFunctions(functions);
  
  // add EntityContainer
  schema.setEntityContainer(getEntityContainer());

  // finally
  List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
  schemas.add(schema);

  return schemas;
}
 
Example 2
Source File: DemoEdmProvider.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
@Override
public List<CsdlSchema> getSchemas() {

  // create Schema
  CsdlSchema schema = new CsdlSchema();
  schema.setNamespace(NAMESPACE);

  // add EntityTypes
  List<CsdlEntityType> entityTypes = new ArrayList<CsdlEntityType>();
  entityTypes.add(getEntityType(ET_PRODUCT_FQN));
  entityTypes.add(getEntityType(ET_CATEGORY_FQN));
  schema.setEntityTypes(entityTypes);
  
  // add actions
  List<CsdlAction> actions = new ArrayList<CsdlAction>();
  actions.addAll(getActions(ACTION_RESET_FQN));
  schema.setActions(actions);
  
  // add functions
  List<CsdlFunction> functions = new ArrayList<CsdlFunction>();
  functions.addAll(getFunctions(FUNCTION_COUNT_CATEGORIES_FQN));
  schema.setFunctions(functions);
  
  // add EntityContainer
  schema.setEntityContainer(getEntityContainer());

  // finally
  List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
  schemas.add(schema);

  return schemas;
}
 
Example 3
Source File: DemoEdmProvider.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
@Override
public List<CsdlSchema> getSchemas() {

  // create Schema
  CsdlSchema schema = new CsdlSchema();
  schema.setNamespace(NAMESPACE);

  // add EntityTypes
  List<CsdlEntityType> entityTypes = new ArrayList<CsdlEntityType>();
  entityTypes.add(getEntityType(ET_PRODUCT_FQN));
  entityTypes.add(getEntityType(ET_CATEGORY_FQN));
  schema.setEntityTypes(entityTypes);
  
  // add actions
  List<CsdlAction> actions = new ArrayList<CsdlAction>();
  actions.addAll(getActions(ACTION_RESET_FQN));
  actions.addAll(getActions(ACTION_PROVIDE_DISCOUNT_FQN));
  actions.addAll(getActions(ACTION_PROVIDE_DISCOUNT_FOR_PRODUCT_FQN));
  schema.setActions(actions);
  
  // add functions
  List<CsdlFunction> functions = new ArrayList<CsdlFunction>();
  functions.addAll(getFunctions(FUNCTION_COUNT_CATEGORIES_FQN));
  functions.addAll(getFunctions(FUNCTION_PROVIDE_DISCOUNT_FQN));
  functions.addAll(getFunctions(FUNCTION_PROVIDE_DISCOUNT_FOR_PRODUCT_FQN));
  schema.setFunctions(functions);
  
  // add EntityContainer
  schema.setEntityContainer(getEntityContainer());

  // finally
  List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
  schemas.add(schema);

  return schemas;
}
 
Example 4
Source File: EdmSchemaImplTest.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
@Override
public List<CsdlSchema> getSchemas() throws ODataException {
  CsdlSchema providerSchema = new CsdlSchema();
  providerSchema.setNamespace(NAMESPACE);
  providerSchema.setAlias(ALIAS);
  CsdlEntityContainer container = new CsdlEntityContainer().setName("container");

  List<CsdlEntitySet> entitySets = new ArrayList<CsdlEntitySet>();
  entitySets.add(new CsdlEntitySet().setName("entitySetName")
      .setType(new FullQualifiedName(NAMESPACE, "entityType1")));
  entitySets
      .add(new CsdlEntitySet().setName("entitySetName2").setType(new FullQualifiedName(NAMESPACE, "entityType2")));
  container.setEntitySets(entitySets);

  List<CsdlSingleton> singletons = new ArrayList<CsdlSingleton>();
  singletons.add(new CsdlSingleton().setName("singletonName")
      .setType(new FullQualifiedName(NAMESPACE, "entityType1")));
  singletons
      .add(new CsdlSingleton().setName("singletonName2").setType(new FullQualifiedName(NAMESPACE, "entityType2")));
  container.setSingletons(singletons);

  List<CsdlActionImport> actionImports = new ArrayList<CsdlActionImport>();
  actionImports.add(new CsdlActionImport().setName("actionImportName").setAction(
      new FullQualifiedName(NAMESPACE, "action1")));
  actionImports.add(new CsdlActionImport().setName("actionImportName2").setAction(
      new FullQualifiedName(NAMESPACE, "action2")));
  container.setActionImports(actionImports);

  List<CsdlFunctionImport> functionImports = new ArrayList<CsdlFunctionImport>();
  functionImports.add(new CsdlFunctionImport().setName("functionImportName").setFunction(
      new FullQualifiedName(NAMESPACE, "function1")));
  functionImports.add(new CsdlFunctionImport().setName("functionImportName2").setFunction(
      new FullQualifiedName(NAMESPACE, "function2")));
  container.setFunctionImports(functionImports);
  providerSchema.setEntityContainer(container);

  List<CsdlTypeDefinition> typeDefinitions = new ArrayList<CsdlTypeDefinition>();
  typeDefinitions.add(new CsdlTypeDefinition().setName("typeDefinition1").setUnderlyingType(
      EdmPrimitiveTypeKind.String.getFullQualifiedName()));
  typeDefinitions.add(new CsdlTypeDefinition().setName("typeDefinition2").setUnderlyingType(
      EdmPrimitiveTypeKind.String.getFullQualifiedName()));
  providerSchema.setTypeDefinitions(typeDefinitions);

  List<CsdlEnumType> enumTypes = new ArrayList<CsdlEnumType>();
  enumTypes.add(new CsdlEnumType().setName("enumType1"));
  enumTypes.add(new CsdlEnumType().setName("enumType2"));
  providerSchema.setEnumTypes(enumTypes);

  List<CsdlEntityType> entityTypes = new ArrayList<CsdlEntityType>();
  entityTypes.add(new CsdlEntityType().setName("entityType1"));
  entityTypes.add(new CsdlEntityType().setName("entityType2")
      .setBaseType(new FullQualifiedName(NAMESPACE, "entityType1")));
  providerSchema.setEntityTypes(entityTypes);

  List<CsdlComplexType> complexTypes = new ArrayList<CsdlComplexType>();
  complexTypes.add(new CsdlComplexType().setName("complexType1"));
  complexTypes.add(new CsdlComplexType().setName("complexType2").setBaseType(
      new FullQualifiedName(NAMESPACE, "complexType1")));
  providerSchema.setComplexTypes(complexTypes);

  List<CsdlAction> actions = new ArrayList<CsdlAction>();
  actions.add(new CsdlAction().setName("action1"));
  actions.add(new CsdlAction().setName("action2"));
  providerSchema.setActions(actions);

  List<CsdlFunction> functions = new ArrayList<CsdlFunction>();
  functions.add(new CsdlFunction().setName("function1"));
  functions.add(new CsdlFunction().setName("function2"));
  providerSchema.setFunctions(functions);

  List<CsdlAnnotations> annotationGroups = new ArrayList<CsdlAnnotations>();
  annotationGroups.add(new CsdlAnnotations().setTarget(NAMESPACE + ".entityType1"));
  annotationGroups.add(new CsdlAnnotations().setTarget(NAMESPACE + ".entityType2"));
  providerSchema.setAnnotationsGroup(annotationGroups);

  List<CsdlTerm> terms = new ArrayList<CsdlTerm>();
  terms.add(new CsdlTerm().setName("term1").setType("Edm.String"));
  terms.add(new CsdlTerm().setName("term2").setType("Edm.String"));
  providerSchema.setTerms(terms);

  ArrayList<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
  schemas.add(providerSchema);
  return schemas;
}
 
Example 5
Source File: MetadataDocumentJsonSerializerTest.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
@Override
 public List<CsdlSchema> getSchemas() throws ODataException {
   List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
   CsdlSchema schema1 = new CsdlSchema();
   schema1.setNamespace(nameSpace1);
   schema1.setAlias("Alias1");
   schemas.add(schema1);
// EntityContainer
   schema1.setEntityContainer(getEntityContainer1());
   
   CsdlSchema schema2 = new CsdlSchema();
   schema2.setNamespace(nameSpace2);
   schemas.add(schema2);
// EntityContainer
   schema2.setEntityContainer(getEntityContainer2());

   
   CsdlSchema schema = new CsdlSchema();
   schema.setNamespace(nameSpace);
   schema.setAlias("Alias");
   schemas.add(schema);

   // EnumTypes
   schema.setEnumTypes(Collections.singletonList(getEnumType(nameENString)));

   // EntityTypes
   schema.setEntityTypes(Arrays.asList(
       getEntityType(nameETAbstract),
       getEntityType(nameETAbstractBase),
       getEntityType(nameET),
       getEntityType(nameETOne),
       getEntityType(nameETTwoKeyNav),
       getEntityType(nameETTwoKeyNavOne)));

   // ComplexTypes
   schema.setComplexTypes(Arrays.asList(
       getComplexType(nameCTTwoPrim),
       getComplexType(nameCTTwoPrimBase),
       getComplexType(nameCTEntityInfo),
       getComplexType(nameCTPrimComp)));

   // TypeDefinitions

   // Actions
   List<CsdlAction> actions1 = getActions(nameUARTPrimParam);
   List<CsdlAction> actions2 = getActions(nameBAETTwoKeyNavRTETTwoKeyNavParam);
   List<CsdlAction> actions3 = getActions(nameBAProp);
   List<CsdlAction> actions = new ArrayList<CsdlAction>();
   actions.addAll(actions1);
   actions.addAll(actions2);
   actions.addAll(actions3);
   
   schema.setActions(actions);

   // Functions
   List<CsdlFunction> function1 = getFunctions(nameUFNRTInt16);
   List<CsdlFunction> function2 = getFunctions(nameBFETTwoKeyNavRTETTwoKeyNavParam);
   List<CsdlFunction> functions = new ArrayList<CsdlFunction>();
   functions.addAll(function1);
   functions.addAll(function2);
   
   schema.setFunctions(functions);

   // EntityContainer
   schema.setEntityContainer(getEntityContainer());

   // Terms
   schema.setTerms(Arrays.asList(
       getTerm(new FullQualifiedName("ns", "term")),
       getTerm(new FullQualifiedName("namespace", "Term1")),
       getTerm(new FullQualifiedName("ns", "Term2")),
       getTerm(new FullQualifiedName("ns", "Term3")),
       getTerm(new FullQualifiedName("ns", "Term4"))));

   // Annotationgroups
   schema.setAnnotationsGroup(Arrays.asList(
       getAnnotationsGroup(new FullQualifiedName("Alias", "ETAbstract"), "Tablett"),
       getAnnotationsGroup(new FullQualifiedName("Alias", "ET"), "T")));
   
   return schemas;
 }
 
Example 6
Source File: MetadataDocumentXmlSerializerTest.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
@Override
public List<CsdlSchema> getSchemas() throws ODataException {
  List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
  CsdlSchema schema = new CsdlSchema();
  schema.setNamespace(nameSpace);
  schema.setAlias("Alias");
  schemas.add(schema);
  
  CsdlSchema schema1 = new CsdlSchema();
  schema1.setNamespace(nameSpace1);
  schema1.setAlias("Alias1");
  schemas.add(schema1);
  
  // Add entity type
  schema1.setEntityTypes(Arrays.asList(getEntityType(nameET)));
  
  // Add entity container
  schema1.setEntityContainer(getEntityContainer1());

  // EnumTypes
  schema.setEnumTypes(Collections.singletonList(getEnumType(nameENString)));

  // EntityTypes
  schema.setEntityTypes(Arrays.asList(
      getEntityType(nameETAbstract),
      getEntityType(nameETAbstractBase)));

  // ComplexTypes
  schema.setComplexTypes(Arrays.asList(
      getComplexType(nameCTTwoPrim),
      getComplexType(nameCTTwoPrimBase)));

  // TypeDefinitions

  // Actions
  List<CsdlAction> actions = new ArrayList<>();
  actions.addAll(getActions(nameUARTPrimParam));
  actions.addAll(getActions(nameUARTOtherEntity));
  actions.addAll(getActions(nameUARTEntity));
  schema.setActions(actions);

  // Functions
  schema.setFunctions(getFunctions(nameUFNRTInt16));
  
  schema.setFunctions(getFunctions(nameUFNRTETAllPrim));

  // EntityContainer
  schema.setEntityContainer(getEntityContainer());

  // Terms
  schema.setTerms(Arrays.asList(
      getTerm(new FullQualifiedName("ns", "term")),
      getTerm(new FullQualifiedName("namespace", "Term1")),
      getTerm(new FullQualifiedName("ns", "Term2")),
      getTerm(new FullQualifiedName("ns", "Term3")),
      getTerm(new FullQualifiedName("ns", "Term4"))));

  // Annotationgroups
  schema.setAnnotationsGroup(Collections.singletonList(
      getAnnotationsGroup(new FullQualifiedName("Alias", "ETAbstract"), "Tablett")));

  return schemas;
}