@Override public Action getAction(String actionName) { int i = actionName.lastIndexOf('.'); String namespace = actionName.substring(0, i); String simpleActionName = actionName.substring(i + 1); Schema schema = schemas.get(namespace); if (schema == null) { throw new IllegalArgumentException("There are no such schema with namespace: " + namespace); } Action action = schema.getAction(simpleActionName); if (action == null) { throw new IllegalArgumentException("Can't find action with name: " + simpleActionName); } return action; }
@Override public Function getFunction(String functionName) { int i = functionName.lastIndexOf('.'); String namespace = functionName.substring(0, i); String simpleFunctionName = functionName.substring(i + 1); Schema schema = schemas.get(namespace); if (schema == null) { throw new IllegalArgumentException("Could not find schema with namespace: " + namespace); } Function function = schema.getFunction(simpleFunctionName); if (function == null) { throw new IllegalArgumentException("Could not find function: " + simpleFunctionName + " in schema with namespace: " + namespace); } return function; }
public EntityDataModelImpl(EntityContainer entityContainer, Iterable<Schema> schemas) { this.entityContainer = entityContainer; Map<String, Schema> schemasByNamespaceBuilder = new LinkedHashMap<>(); Map<String, Schema> schemasByAliasBuilder = new LinkedHashMap<>(); for (Schema schema : schemas) { schemasByNamespaceBuilder.put(schema.getNamespace(), schema); String alias = schema.getAlias(); if (!isNullOrEmpty(alias)) { schemasByAliasBuilder.put(alias, schema); } } this.schemasByNamespace = Collections.unmodifiableMap(schemasByNamespaceBuilder); this.schemasByAlias = Collections.unmodifiableMap(schemasByAliasBuilder); }
xmlWriter.writeStartElement(SCHEMA); xmlWriter.writeDefaultNamespace(EDM_NS); xmlWriter.writeAttribute(NAMESPACE, schema.getNamespace()); for (Type type : schema.getTypes()) { switch (type.getMetaType()) { case ENTITY:
private void buildSchemas(Map<String, Schema> schemas) { for (SchemaImpl.Builder builder : schemaBuilders.values()) { Schema schema = builder.build(); schemas.put(schema.getNamespace(), schema); } }
@Override public StructuredType getStructuredType(String fullyQualifiedTypeName) { int i = fullyQualifiedTypeName.lastIndexOf('.'); String namespace = fullyQualifiedTypeName.substring(0, i); String simpleTypeName = fullyQualifiedTypeName.substring(i + 1); Schema schema = schemas.get(namespace); if (schema != null) { Type type = schema.getType(simpleTypeName); return type instanceof StructuredType ? (StructuredType) type : null; } else { return null; } }
xmlWriter.writeStartElement(SCHEMA); xmlWriter.writeDefaultNamespace(EDM_NS); xmlWriter.writeAttribute(NAMESPACE, schema.getNamespace()); for (Type type : schema.getTypes()) { switch (type.getMetaType()) { case ENTITY:
private void buildSchemas(Map<String, Schema> schemas) { for (SchemaImpl.Builder builder : schemaBuilders.values()) { Schema schema = builder.build(); schemas.put(schema.getNamespace(), schema); } }
@Override public StructuredType getStructuredType(String fullyQualifiedTypeName) { int i = fullyQualifiedTypeName.lastIndexOf('.'); String namespace = fullyQualifiedTypeName.substring(0, i); String simpleTypeName = fullyQualifiedTypeName.substring(i + 1); Schema schema = schemas.get(namespace); if (schema != null) { Type type = schema.getType(simpleTypeName); return type instanceof StructuredType ? (StructuredType) type : null; } else { return null; } }
@Override public Action getAction(String actionName) { int i = actionName.lastIndexOf('.'); String namespace = actionName.substring(0, i); String simpleActionName = actionName.substring(i + 1); Schema schema = schemas.get(namespace); if (schema == null) { throw new IllegalArgumentException("There are no such schema with namespace: " + namespace); } Action action = schema.getAction(simpleActionName); if (action == null) { throw new IllegalArgumentException("Can't find action with name: " + simpleActionName); } return action; }
@Override public Function getFunction(String functionName) { int i = functionName.lastIndexOf('.'); String namespace = functionName.substring(0, i); String simpleFunctionName = functionName.substring(i + 1); Schema schema = schemas.get(namespace); if (schema == null) { throw new IllegalArgumentException("Could not find schema with namespace: " + namespace); } Function function = schema.getFunction(simpleFunctionName); if (function == null) { throw new IllegalArgumentException("Could not find function: " + simpleFunctionName + " in schema with namespace: " + namespace); } return function; }
public EntityDataModelImpl(EntityContainer entityContainer, Iterable<Schema> schemas) { this.entityContainer = entityContainer; Map<String, Schema> schemasByNamespaceBuilder = new LinkedHashMap<>(); Map<String, Schema> schemasByAliasBuilder = new LinkedHashMap<>(); for (Schema schema : schemas) { schemasByNamespaceBuilder.put(schema.getNamespace(), schema); String alias = schema.getAlias(); if (!isNullOrEmpty(alias)) { schemasByAliasBuilder.put(alias, schema); } } this.schemasByNamespace = Collections.unmodifiableMap(schemasByNamespaceBuilder); this.schemasByAlias = Collections.unmodifiableMap(schemasByAliasBuilder); }
String firstSchemaNamespace = schemas.values().iterator().next().getNamespace();
@Override public Type getType(String fullyQualifiedTypeName) { // Check if it is one of the standard types Type standardType = NAME_TO_STANDARD_TYPE.get(fullyQualifiedTypeName); if (standardType != null) { return standardType; } int i = fullyQualifiedTypeName.lastIndexOf('.'); if (i < 0) { throw new IllegalArgumentException( "Name must be a fully-qualified type name, prefixed with a namespace or schema alias: " + fullyQualifiedTypeName); } String namespaceOrAlias = fullyQualifiedTypeName.substring(0, i); String simpleName = fullyQualifiedTypeName.substring(i + 1); Schema schema = getSchema(namespaceOrAlias); return schema != null ? schema.getType(simpleName) : null; }
/** * Gets the action by the specified name, throw an exception if no action with the specified name * exists. * * @param entityDataModel The entity data model. * @param actionName The name of action. * @return the Action instance specified by given actionName. */ public static Action getAndCheckAction(EntityDataModel entityDataModel, String actionName) { int namespaceLastIndex = actionName.lastIndexOf('.'); String namespace = actionName.substring(0, namespaceLastIndex); String simpleActionName = actionName.substring(namespaceLastIndex + 1); Schema schema = entityDataModel.getSchema(namespace); if (schema == null) { throw new ODataSystemException("Could not find schema in entity data model with namespace: " + namespace); } Action action = schema.getAction(simpleActionName); if (action == null) { throw new ODataSystemException("Action not found in entity data model: " + actionName); } return action; }
public static Function getAndCheckFunction(EntityDataModel entityDataModel, String functionName) { int namespaceLastIndex = functionName.lastIndexOf('.'); String namespace = functionName.substring(0, namespaceLastIndex); String simpleFunctionName = functionName.substring(namespaceLastIndex + 1); Schema schema = entityDataModel.getSchema(namespace); if (schema == null) { throw new ODataSystemException("Could not find schema in entity data model with namespace: " + namespace); } Function function = schema.getFunction(simpleFunctionName); if (function == null) { throw new ODataSystemException("Function not found in entity data model: " + functionName); } return function; }
String firstSchemaNamespace = schemas.values().iterator().next().getNamespace();
@Override public Type getType(String fullyQualifiedTypeName) { // Check if it is one of the standard types Type standardType = NAME_TO_STANDARD_TYPE.get(fullyQualifiedTypeName); if (standardType != null) { return standardType; } int i = fullyQualifiedTypeName.lastIndexOf('.'); if (i < 0) { throw new IllegalArgumentException( "Name must be a fully-qualified type name, prefixed with a namespace or schema alias: " + fullyQualifiedTypeName); } String namespaceOrAlias = fullyQualifiedTypeName.substring(0, i); String simpleName = fullyQualifiedTypeName.substring(i + 1); Schema schema = getSchema(namespaceOrAlias); return schema != null ? schema.getType(simpleName) : null; }
/** * Gets the action by the specified name, throw an exception if no action with the specified name * exists. * * @param entityDataModel The entity data model. * @param actionName The name of action. * @return the Action instance specified by given actionName. */ public static Action getAndCheckAction(EntityDataModel entityDataModel, String actionName) { int namespaceLastIndex = actionName.lastIndexOf('.'); String namespace = actionName.substring(0, namespaceLastIndex); String simpleActionName = actionName.substring(namespaceLastIndex + 1); Schema schema = entityDataModel.getSchema(namespace); if (schema == null) { throw new ODataSystemException("Could not find schema in entity data model with namespace: " + namespace); } Action action = schema.getAction(simpleActionName); if (action == null) { throw new ODataSystemException("Action not found in entity data model: " + actionName); } return action; }
public static Function getAndCheckFunction(EntityDataModel entityDataModel, String functionName) { int namespaceLastIndex = functionName.lastIndexOf('.'); String namespace = functionName.substring(0, namespaceLastIndex); String simpleFunctionName = functionName.substring(namespaceLastIndex + 1); Schema schema = entityDataModel.getSchema(namespace); if (schema == null) { throw new ODataSystemException("Could not find schema in entity data model with namespace: " + namespace); } Function function = schema.getFunction(simpleFunctionName); if (function == null) { throw new ODataSystemException("Function not found in entity data model: " + functionName); } return function; }