当前位置: 首页>>代码示例>>Java>>正文


Java EdmSimpleTypeKind类代码示例

本文整理汇总了Java中org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind的典型用法代码示例。如果您正苦于以下问题:Java EdmSimpleTypeKind类的具体用法?Java EdmSimpleTypeKind怎么用?Java EdmSimpleTypeKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EdmSimpleTypeKind类属于org.apache.olingo.odata2.api.edm包,在下文中一共展示了EdmSimpleTypeKind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFunctionImport

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
@Override
public FunctionImport getFunctionImport()
{
   // Returns the Result Set of the given query as String.
   ReturnType rt = new ReturnType()
         .setMultiplicity(EdmMultiplicity.ZERO_TO_ONE)
         .setTypeName(EdmSimpleTypeKind.String.getFullQualifiedName());

   // One required param: the SPARQL query.
   List<FunctionImportParameter> params = new ArrayList<>();
   params.add(new FunctionImportParameter()
         .setName("query")
         .setType(EdmSimpleTypeKind.String)
         .setFacets(new Facets().setNullable(false)));

   return new FunctionImport()
         .setName(NAME)
         .setHttpMethod("GET")
         .setParameters(params)
         .setReturnType(rt);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:22,代码来源:Sparql.java

示例2: valueOfStringBoolean

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
@Test
public void valueOfStringBoolean() throws Exception {
  final EdmSimpleType instance = EdmSimpleTypeKind.Boolean.getEdmSimpleTypeInstance();

  assertEquals(true, instance.valueOfString("true", EdmLiteralKind.DEFAULT, null, Boolean.class));
  assertEquals(false, instance.valueOfString("false", EdmLiteralKind.JSON, null, Boolean.class));
  assertEquals(true, instance.valueOfString("1", EdmLiteralKind.URI, null, Boolean.class));
  assertEquals(false, instance.valueOfString("0", EdmLiteralKind.URI, null, Boolean.class));

  expectErrorInValueOfString(instance, "True", EdmLiteralKind.DEFAULT, null,
      EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT);
  expectErrorInValueOfString(instance, "-1", EdmLiteralKind.JSON, null,
      EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT);
  expectErrorInValueOfString(instance, "FALSE", EdmLiteralKind.URI, null,
      EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT);

  expectTypeErrorInValueOfString(instance, "1", EdmLiteralKind.DEFAULT);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:19,代码来源:EdmSimpleTypeTest.java

示例3: buildSimpleProperty

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
private SimpleProperty buildSimpleProperty(final Attribute<?, ?> jpaAttribute, final SimpleProperty simpleProperty,
    final JoinColumn joinColumn)
    throws ODataJPAModelException, ODataJPARuntimeException {

  boolean isForeignKey = joinColumn != null;
  JPAEdmNameBuilder.build(JPAEdmProperty.this, isBuildModeComplexType, skipDefaultNaming, isForeignKey);
  EdmSimpleTypeKind simpleTypeKind = JPATypeConverter
      .convertToEdmSimpleType(jpaAttribute
          .getJavaType(), jpaAttribute);
  simpleProperty.setType(simpleTypeKind);
  Facets facets = JPAEdmFacets.createAndSet(jpaAttribute, simpleProperty);
  if(isForeignKey) {
    facets.setNullable(joinColumn.nullable());
  }

  return simpleProperty;

}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:19,代码来源:JPAEdmProperty.java

示例4: createKeyPredicates

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
private List<KeyPredicate> createKeyPredicates(final boolean toThrowException) throws EdmException {
  KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
  EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
  EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
  JPAEdmMappingImpl edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
  EasyMock.expect(edmMapping.getJPAType())
  .andStubReturn(null);
  EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soid");
  EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
  EasyMock.expect(edmProperty.getName()).andStubReturn("soid");
  EdmSimpleType edmType = EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance();
  if (toThrowException) {
    EasyMock.expect(edmProperty.getType()).andStubThrow(new EdmException(null));
  } else {
    EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
  }
  EasyMock.expect(keyPredicate.getProperty()).andStubReturn(edmProperty);

  EasyMock.replay(edmMapping, edmProperty, keyPredicate);
  List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
  keyPredicates.add(keyPredicate);
  return keyPredicates;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:24,代码来源:JPQLJoinSelectSingleContextTest.java

示例5: testBuildSimpleQuery

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
/**
 * Test method for {@link org.apache.olingo.odata2.processor.jpa.jpql.JPQLSelectSingleStatementBuilder#build)}.
 * @throws EdmException
 * @throws ODataJPARuntimeException
 */

@Test
public void testBuildSimpleQuery() throws EdmException, ODataJPARuntimeException {
  EdmSimpleType edmType = EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance();
  JPQLSelectSingleContext JPQLSelectSingleContextImpl = createSelectContext(edmType);
  JPQLSelectSingleStatementBuilder = new JPQLSelectSingleStatementBuilder(JPQLSelectSingleContextImpl);

  String query = JPQLSelectSingleStatementBuilder.build().toString();
  query = query.substring(0, query.indexOf("?"));
  Map<String, Map<Integer, Object>> positionalParameters = 
      ODataParameterizedWhereExpressionUtil.getParameterizedQueryMap();
  for (Entry<String, Map<Integer, Object>> param : positionalParameters.entrySet()) {
    for (Entry<Integer, Object> postionalParam : param.getValue().entrySet()) {
      query += postionalParam.getValue();
    }
  }
  
  assertEquals("SELECT E1 FROM SalesOrderHeader E1 WHERE E1.Field1 = 1", query);

}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:26,代码来源:JPQLSelectSingleStatementBuilderTest.java

示例6: testBuildQueryWithSpecialChars

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
/**
 * Test method for {@link org.apache.olingo.odata2.processor.jpa.jpql.JPQLSelectSingleStatementBuilder#build)}.
 * @throws EdmException
 * @throws ODataJPARuntimeException
 */

@Test
public void testBuildQueryWithSpecialChars() throws EdmException, ODataJPARuntimeException {
  EdmSimpleType edmType = EdmSimpleTypeKind.String.getEdmSimpleTypeInstance();
  JPQLSelectSingleContext JPQLSelectSingleContextImpl = createSelectContext(edmType);
  JPQLSelectSingleStatementBuilder = new JPQLSelectSingleStatementBuilder(JPQLSelectSingleContextImpl);

  String query = JPQLSelectSingleStatementBuilder.build().toString();
  query = query.substring(0, query.indexOf("?"));
  Map<String, Map<Integer, Object>> positionalParameters = 
      ODataParameterizedWhereExpressionUtil.getParameterizedQueryMap();
  for (Entry<String, Map<Integer, Object>> param : positionalParameters.entrySet()) {
    for (Entry<Integer, Object> postionalParam : param.getValue().entrySet()) {
      query += postionalParam.getValue();
    }
  }
  
  assertEquals("SELECT E1 FROM SalesOrderHeader E1 WHERE E1.Field1 LIKE  MiMe-Id1", query);

}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:26,代码来源:JPQLSelectSingleStatementBuilderTest.java

示例7: testFunctionImportNoName

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
/**
 * Test Case - Function Import with no names. Default name is Java method
 * name.
 */
@Test
public void testFunctionImportNoName() {
  VARIANT = 3;

  build();

  List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();

  assertEquals(functionImportList.size(), 1);

  FunctionImport functionImport = functionImportList.get(0);
  assertEquals(functionImport.getName(), "method3");
  assertNotNull(functionImport.getMapping());

  ReturnType returnType = functionImport.getReturnType();
  assertNotNull(returnType);
  assertEquals(EdmMultiplicity.ONE, returnType.getMultiplicity());
  assertEquals(returnType.getTypeName().toString(), EdmSimpleTypeKind.Int32.getFullQualifiedName().toString());
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:24,代码来源:JPAEdmFunctionImportTest.java

示例8: valueOfStringInt32

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
@Test
public void valueOfStringInt32() throws Exception {
  final EdmSimpleType instance = EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance();

  assertEquals(Byte.valueOf((byte) 1), instance.valueOfString("1", EdmLiteralKind.DEFAULT, null, Byte.class));
  assertEquals(Short.valueOf((short) 2), instance.valueOfString("2", EdmLiteralKind.JSON, null, Short.class));
  assertEquals(Integer.valueOf(-10000000), instance.valueOfString("-10000000", EdmLiteralKind.URI, null,
      Integer.class));
  assertEquals(Long.valueOf(10000000), instance.valueOfString("10000000", EdmLiteralKind.URI, null, Long.class));

  expectErrorInValueOfString(instance, "-2147483649", EdmLiteralKind.DEFAULT, null,
      EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT);
  expectErrorInValueOfString(instance, "1.0", EdmLiteralKind.DEFAULT, null,
      EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT);

  expectTypeErrorInValueOfString(instance, "1", EdmLiteralKind.DEFAULT);
  expectUnconvertibleErrorInValueOfString(instance, "-129", Byte.class);
  expectUnconvertibleErrorInValueOfString(instance, "128", Byte.class);
  expectUnconvertibleErrorInValueOfString(instance, "-32769", Short.class);
  expectUnconvertibleErrorInValueOfString(instance, "32768", Short.class);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:22,代码来源:EdmSimpleTypeTest.java

示例9: getType

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
@Override
public EdmType getType() throws EdmException {
  if (edmType == null) {
    final String namespace = typeName.getNamespace();
    if (EdmSimpleType.EDM_NAMESPACE.equals(typeName.getNamespace())) {
      edmType = EdmSimpleTypeFacadeImpl.getEdmSimpleType(EdmSimpleTypeKind.valueOf(typeName.getName()));
    } else {
      edmType = edm.getComplexType(namespace, typeName.getName());
    }
    if (edmType == null) {
      edmType = edm.getEntityType(namespace, typeName.getName());
    }

    if (edmType == null) {
      throw new EdmException(EdmException.COMMON);
    }

  }
  return edmType;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:21,代码来源:EdmTypedImplProv.java

示例10: valueToStringSByte

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
@Test
public void valueToStringSByte() throws Exception {
  final EdmSimpleType instance = EdmSimpleTypeKind.SByte.getEdmSimpleTypeInstance();

  assertEquals("0", instance.valueToString(0, EdmLiteralKind.DEFAULT, null));
  assertEquals("0", instance.valueToString(0, EdmLiteralKind.JSON, null));
  assertEquals("0", instance.valueToString(0, EdmLiteralKind.URI, null));
  assertEquals("8", instance.valueToString((byte) 8, EdmLiteralKind.DEFAULT, null));
  assertEquals("16", instance.valueToString((short) 16, EdmLiteralKind.DEFAULT, null));
  assertEquals("32", instance.valueToString(Integer.valueOf(32), EdmLiteralKind.DEFAULT, null));
  assertEquals("64", instance.valueToString(64L, EdmLiteralKind.DEFAULT, null));

  expectErrorInValueToString(instance, -129, EdmLiteralKind.DEFAULT, null,
      EdmSimpleTypeException.VALUE_ILLEGAL_CONTENT);
  expectErrorInValueToString(instance, 128, EdmLiteralKind.DEFAULT, null,
      EdmSimpleTypeException.VALUE_ILLEGAL_CONTENT);
  expectErrorInValueToString(instance, 'A', EdmLiteralKind.DEFAULT, null,
      EdmSimpleTypeException.VALUE_TYPE_NOT_SUPPORTED);
  expectErrorInValueToString(instance, 1, null, null, EdmSimpleTypeException.LITERAL_KIND_MISSING);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:21,代码来源:EdmSimpleTypeTest.java

示例11: setup

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception {

  EdmProvider edmProvider = mock(EdmProvider.class);
  EdmImplProv edmImplProv = new EdmImplProv(edmProvider);

  mappedObject = new EdmMappingTest();

  Mapping propertySimpleMapping = new Mapping().setInternalName("value").setObject(mappedObject);
  CustomizableFeedMappings propertySimpleFeedMappings = new CustomizableFeedMappings().setFcKeepInContent(true);
  SimpleProperty propertySimple =
      new SimpleProperty().setName("PropertyName").setType(EdmSimpleTypeKind.String)
          .setMimeType("mimeType").setMapping(propertySimpleMapping).setCustomizableFeedMappings(
              propertySimpleFeedMappings);
  propertySimpleProvider = new EdmSimplePropertyImplProv(edmImplProv, propertySimple);

  NavigationProperty navProperty =
      new NavigationProperty().setName("navProperty").setFromRole("fromRole").setToRole("toRole").setMapping(
          propertySimpleMapping);
  navPropertyProvider = new EdmNavigationPropertyImplProv(edmImplProv, navProperty);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:22,代码来源:EdmMappingTest.java

示例12: testDecimalCompatibility

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
@Test
public void testDecimalCompatibility() {
  testCompatibility(EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance(),
      Bit.getInstance(),
      Uint7.getInstance(),
      EdmSimpleTypeKind.Byte.getEdmSimpleTypeInstance(),
      EdmSimpleTypeKind.SByte.getEdmSimpleTypeInstance(),
      EdmSimpleTypeKind.Int16.getEdmSimpleTypeInstance(),
      EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance(),
      EdmSimpleTypeKind.Int64.getEdmSimpleTypeInstance(),
      EdmSimpleTypeKind.Single.getEdmSimpleTypeInstance(),
      EdmSimpleTypeKind.Double.getEdmSimpleTypeInstance(),
      EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance());
  assertFalse(EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance().isCompatible(
      EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()));
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:17,代码来源:EdmSimpleTypeTest.java

示例13: valueOfStringSByte

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
@Test
public void valueOfStringSByte() throws Exception {
  final EdmSimpleType instance = EdmSimpleTypeKind.SByte.getEdmSimpleTypeInstance();

  assertEquals(Byte.valueOf((byte) 1), instance.valueOfString("1", EdmLiteralKind.DEFAULT, null, Byte.class));
  assertEquals(Short.valueOf((short) -2), instance.valueOfString("-2", EdmLiteralKind.JSON, null, Short.class));
  assertEquals(Byte.valueOf((byte) 127), instance.valueOfString("127", EdmLiteralKind.URI, null, Byte.class));
  assertEquals(Byte.valueOf((byte) -128), instance.valueOfString("-128", EdmLiteralKind.URI, null, Byte.class));
  assertEquals(Integer.valueOf(0), instance.valueOfString("0", EdmLiteralKind.DEFAULT, null, Integer.class));
  assertEquals(Long.valueOf(0), instance.valueOfString("0", EdmLiteralKind.DEFAULT, null, Long.class));

  expectErrorInValueOfString(instance, "128", EdmLiteralKind.DEFAULT, null,
      EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT);
  expectErrorInValueOfString(instance, "-129", EdmLiteralKind.JSON, null,
      EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT);
  expectErrorInValueOfString(instance, "1.0", EdmLiteralKind.URI, null,
      EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT);

  expectTypeErrorInValueOfString(instance, "1", EdmLiteralKind.DEFAULT);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:21,代码来源:EdmSimpleTypeTest.java

示例14: compareTypes

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
@Test
public void compareTypes() {
  compare(EdmSimpleTypeKind.Binary);
  compare(EdmSimpleTypeKind.Boolean);
  compare(EdmSimpleTypeKind.Byte);
  compare(EdmSimpleTypeKind.SByte);
  compare(EdmSimpleTypeKind.DateTime);
  compare(EdmSimpleTypeKind.DateTimeOffset);
  compare(EdmSimpleTypeKind.Decimal);
  compare(EdmSimpleTypeKind.Double);
  compare(EdmSimpleTypeKind.Guid);
  compare(EdmSimpleTypeKind.Int16);
  compare(EdmSimpleTypeKind.Int32);
  compare(EdmSimpleTypeKind.Int64);
  compare(EdmSimpleTypeKind.Single);
  compare(EdmSimpleTypeKind.Time);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:18,代码来源:EdmSimpleTypeFacadeTest.java

示例15: validate

import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; //导入依赖的package包/类
@Test
public void validate() throws Exception {
  for (EdmSimpleTypeKind kind : EdmSimpleTypeKind.values()) {
    if (kind == EdmSimpleTypeKind.Null) {
      continue;
    }
    final EdmSimpleType instance = kind.getEdmSimpleTypeInstance();
    assertTrue(instance.validate(null, null, null));
    assertTrue(instance.validate(null, null, getNullableFacets(null)));
    assertTrue(instance.validate(null, null, getNullableFacets(true)));
    assertFalse(instance.validate(null, null, getNullableFacets(false)));
    assertFalse(instance.validate("", null, null));
    assertFalse(instance.validate("ä", EdmLiteralKind.DEFAULT, getUnicodeFacets(false)));
    assertFalse(instance.validate("ä", EdmLiteralKind.URI, null));
  }

  assertTrue(EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance().validate("abcd", EdmLiteralKind.DEFAULT,
      getMaxLengthFacets(3)));
  assertFalse(EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance().validate("abcd", EdmLiteralKind.DEFAULT,
      getMaxLengthFacets(2)));

  assertTrue(EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance().validate("1.2", EdmLiteralKind.DEFAULT,
      getPrecisionScaleFacets(null, null)));
  assertFalse(EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance().validate("1.2", EdmLiteralKind.DEFAULT,
      getPrecisionScaleFacets(null, 0)));
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:EdmSimpleTypeTest.java


注:本文中的org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。