public B setType(Type type, boolean isCollectionForStructureProperty) { this.typeName = type.getFullyQualifiedName(); this.isCollection = isCollectionForStructureProperty; return self; }
public B setType(Type type, boolean isCollectionForStructureProperty) { this.typeName = type.getFullyQualifiedName(); this.isCollection = isCollectionForStructureProperty; return self; }
@Override public String toString() { if (collection) { return "Collection(" + type.getFullyQualifiedName() + ")"; } else { return type.getFullyQualifiedName(); } } }
@Override public String toString() { if (collection) { return "Collection(" + type.getFullyQualifiedName() + ")"; } else { return type.getFullyQualifiedName(); } } }
public B setBaseType(Type baseType) { return setBaseTypeName(baseType.getFullyQualifiedName()); }
public B setBaseType(Type baseType) { return setBaseTypeName(baseType.getFullyQualifiedName()); }
/** * If it's the first batch request call - start transaction. * @param type The type of the entity to request a datasource for */ private TransactionalDataSource getTransactionalDataSource( ODataRequestContext odataRequestContext, Type type) throws ODataException { DataSource dataSource = dataSourceFactory.getDataSource(odataRequestContext, type.getFullyQualifiedName()); String dataSourceKey = dataSource.getClass().toString(); if (dataSourceMap.containsKey(dataSourceKey)) { return dataSourceMap.get(dataSourceKey); } else { TransactionalDataSource transactionalDataSource = dataSource.startTransaction(); dataSourceMap.put(dataSourceKey, transactionalDataSource); return transactionalDataSource; } }
/** * If it's the first batch request call - start transaction. * @param type The type of the entity to request a datasource for */ private TransactionalDataSource getTransactionalDataSource( ODataRequestContext odataRequestContext, Type type) throws ODataException { DataSource dataSource = dataSourceFactory.getDataSource(odataRequestContext, type.getFullyQualifiedName()); String dataSourceKey = dataSource.getClass().toString(); if (dataSourceMap.containsKey(dataSourceKey)) { return dataSourceMap.get(dataSourceKey); } else { TransactionalDataSource transactionalDataSource = dataSource.startTransaction(); dataSourceMap.put(dataSourceKey, transactionalDataSource); return transactionalDataSource; } }
/** * Validates the target type. * * @param entity an entity * @throws com.sdl.odata.api.processor.ODataProcessorException * @throws com.sdl.odata.api.processor.datasource.ODataTargetTypeException */ public static void validateTargetType(Object entity, ODataRequest request, EntityDataModel entityDataModel, ODataUri oDataUri) throws ODataProcessorException, ODataTargetTypeException { if (!entityDataModel.getType( entity.getClass()).getFullyQualifiedName().equals(getTargetType(request, entityDataModel, oDataUri).typeName())) { throw new ODataProcessorException(PROCESSOR_ERROR, "Entity to persist does not match specified Resource name"); } }
/** * Validates the target type. * * @param entity an entity * @throws com.sdl.odata.api.processor.ODataProcessorException * @throws com.sdl.odata.api.processor.datasource.ODataTargetTypeException */ public static void validateTargetType(Object entity, ODataRequest request, EntityDataModel entityDataModel, ODataUri oDataUri) throws ODataProcessorException, ODataTargetTypeException { if (!entityDataModel.getType( entity.getClass()).getFullyQualifiedName().equals(getTargetType(request, entityDataModel, oDataUri).typeName())) { throw new ODataProcessorException(PROCESSOR_ERROR, "Entity to persist does not match specified Resource name"); } }
/** * Validates the target type. * * @param entity an entity * @throws com.sdl.odata.api.processor.ODataProcessorException * @throws com.sdl.odata.api.processor.datasource.ODataTargetTypeException */ protected void validateTargetType(Object entity) throws ODataProcessorException, ODataTargetTypeException { if (!getEntityDataModel().getType( entity.getClass()).getFullyQualifiedName().equals(getTargetType().typeName())) { throw new ODataProcessorException(PROCESSOR_ERROR, "Entity to persist does not match specified Resource name"); } }
/** * Checks if the specified OData type is a complex type and throws an exception if it is not. * * @param type The OData type. * @return The OData type. * @throws ODataSystemException If the OData type is not a complex type. */ public static ComplexType checkIsComplexType(Type type) { if (!isComplexType(type)) { throw new ODataSystemException("A complex type is required, but '" + type.getFullyQualifiedName() + "' is not a complex type: " + type.getMetaType()); } return (ComplexType) type; }
/** * Checks if the specified OData type is a complex type and throws an exception if it is not. * * @param type The OData type. * @return The OData type. * @throws ODataSystemException If the OData type is not a complex type. */ public static ComplexType checkIsComplexType(Type type) { if (!isComplexType(type)) { throw new ODataSystemException("A complex type is required, but '" + type.getFullyQualifiedName() + "' is not a complex type: " + type.getMetaType()); } return (ComplexType) type; }
/** * Validates the target type. * * @param entity an entity * @throws com.sdl.odata.api.processor.ODataProcessorException * @throws com.sdl.odata.api.processor.datasource.ODataTargetTypeException */ protected void validateTargetType(Object entity) throws ODataProcessorException, ODataTargetTypeException { if (!getEntityDataModel().getType( entity.getClass()).getFullyQualifiedName().equals(getTargetType().typeName())) { throw new ODataProcessorException(PROCESSOR_ERROR, "Entity to persist does not match specified Resource name"); } }
/** * Checks if the specified OData type is a primitive type and throws an exception if it is not. * * @param type The OData type. * @return The OData type. * @throws ODataSystemException If the OData type is not a primitive type. */ public static PrimitiveType checkIsPrimitiveType(Type type) { if (!isPrimitiveType(type)) { throw new ODataSystemException("A primitive type is required, but '" + type.getFullyQualifiedName() + "' is not a primitive type: " + type.getMetaType()); } return (PrimitiveType) type; }
/** * Checks if the specified OData type is an entity type and throws an exception if it is not. * * @param type The OData type. * @return The OData type. * @throws ODataSystemException If the OData type is not an entity type. */ public static EntityType checkIsEntityType(Type type) { if (!isEntityType(type)) { throw new ODataSystemException("An entity type is required, but '" + type.getFullyQualifiedName() + "' is not an entity type: " + type.getMetaType()); } return (EntityType) type; }
/** * Checks if the specified OData type is a primitive type and throws an exception if it is not. * * @param type The OData type. * @return The OData type. * @throws ODataSystemException If the OData type is not a primitive type. */ public static PrimitiveType checkIsPrimitiveType(Type type) { if (!isPrimitiveType(type)) { throw new ODataSystemException("A primitive type is required, but '" + type.getFullyQualifiedName() + "' is not a primitive type: " + type.getMetaType()); } return (PrimitiveType) type; }
/** * Checks if the specified OData type is a structured type and throws an exception if it is not. * * @param type The OData type. * @return The OData type. * @throws ODataSystemException If the OData type is not a structured type. */ public static StructuredType checkIsStructuredType(Type type) { if (!isStructuredType(type)) { throw new ODataSystemException("A structured type is required, but '" + type.getFullyQualifiedName() + "' is not a structured type: " + type.getMetaType()); } return (StructuredType) type; }
/** * Checks if the specified OData type is an entity type and throws an exception if it is not. * * @param type The OData type. * @return The OData type. * @throws ODataSystemException If the OData type is not an entity type. */ public static EntityType checkIsEntityType(Type type) { if (!isEntityType(type)) { throw new ODataSystemException("An entity type is required, but '" + type.getFullyQualifiedName() + "' is not an entity type: " + type.getMetaType()); } return (EntityType) type; }
/** * Checks if the specified OData type is a structured type and throws an exception if it is not. * * @param type The OData type. * @return The OData type. * @throws ODataSystemException If the OData type is not a structured type. */ public static StructuredType checkIsStructuredType(Type type) { if (!isStructuredType(type)) { throw new ODataSystemException("A structured type is required, but '" + type.getFullyQualifiedName() + "' is not a structured type: " + type.getMetaType()); } return (StructuredType) type; }