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


Java EdmNavigationProperty.Builder方法代码示例

本文整理汇总了Java中org.odata4j.edm.EdmNavigationProperty.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java EdmNavigationProperty.Builder方法的具体用法?Java EdmNavigationProperty.Builder怎么用?Java EdmNavigationProperty.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.odata4j.edm.EdmNavigationProperty的用法示例。


在下文中一共展示了EdmNavigationProperty.Builder方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseEdmNavigationProperty

import org.odata4j.edm.EdmNavigationProperty; //导入方法依赖的package包/类
private EdmNavigationProperty.Builder parseEdmNavigationProperty(XMLEventReader2 reader, XMLEvent2 event) {
  List<EdmAnnotation<?>> annotElements = new ArrayList<EdmAnnotation<?>>();

  StartElement2 navPropStartElement = event.asStartElement();
  String associationName = navPropStartElement.getAttributeByName("Name").getValue();
  String relationshipName = navPropStartElement.getAttributeByName("Relationship").getValue();
  String fromRoleName = navPropStartElement.getAttributeByName("FromRole").getValue();
  String toRoleName = navPropStartElement.getAttributeByName("ToRole").getValue();
  Attribute2 containsTargetAttr = navPropStartElement.getAttributeByName("ContainsTarget");
  boolean containsTarget = false;
  if (containsTargetAttr != null) {
    containsTarget = Boolean.parseBoolean(containsTargetAttr.getValue());
  }
  while (reader.hasNext()) {
    event = reader.nextEvent();
    if (event.isStartElement()) {
      EdmAnnotation<?> anElement = getAnnotationElements(event, reader);
      if (anElement != null) {
        annotElements.add(anElement);
      }
    }
    if (isEndElement(event, navPropStartElement.getName())) {
      return EdmNavigationProperty.newBuilder(associationName)
          .setRelationshipName(relationshipName)
          .setFromToName(fromRoleName, toRoleName)
          .setAnnotations(getAnnotations(navPropStartElement))
          .setAnnotationElements(annotElements)
          .setContainsTarget(containsTarget);
    }
  }
  throw new UnsupportedOperationException();
}
 
开发者ID:teiid,项目名称:oreva,代码行数:33,代码来源:EdmxFormatParser.java

示例2: associate

import org.odata4j.edm.EdmNavigationProperty; //导入方法依赖的package包/类
static EdmAssociation.Builder associate(
        final String namespace,
        final EdmEntityType.Builder type1,
        final EdmEntityType.Builder type2,
        final String type1AssociationEndName,
        final String type2AssociationEndName,
        final EdmMultiplicity type1Multiplicity,
        final EdmMultiplicity type2Multiplicity,
        final List<EdmAnnotation<?>> type1NavPropAnnotations,
        final List<EdmAnnotation<?>> type2NavPropAnnotations,
        final String paramAssoc1Name, final String paramAssoc2Name) {
    String type1EndRole = type1AssociationEndName;
    String type2EndRole = type2AssociationEndName;
    if (type1EndRole == null) {
        type1EndRole = type1.getName() + "-" + type2.getName();
    }
    if (type2EndRole == null) {
        type2EndRole = type2.getName() + "-" + type1.getName();
    }
    EdmAssociation.Builder ret = EdmAssociation
            .newBuilder()
            .setEnds(
                    EdmAssociationEnd.newBuilder()
                            .setType(type1)
                            .setTypeName(type1.getName()) // なぜか setTypeをしただけだと使えず、setTypeNameもしないといけない。
                            .setMultiplicity(type1Multiplicity)
                            .setRole(type1EndRole),
                    EdmAssociationEnd.newBuilder()
                            .setType(type2)
                            .setTypeName(type2.getName())
                            .setMultiplicity(type2Multiplicity)
                            .setRole(type2EndRole))
            .setName(type1.getName() + "-" + type2.getName() + "-assoc")
            .setNamespace(namespace);

    // create nav props
    String assoc1Name = paramAssoc1Name;
    String assoc2Name = paramAssoc2Name;
    if (assoc1Name == null) {
        assoc1Name = "_" + type1.getName();
    }
    if (assoc2Name == null) {
        assoc2Name = "_" + type2.getName();
    }
    EdmNavigationProperty.Builder np1 = EdmNavigationProperty.newBuilder(assoc2Name)
            .setFromTo(ret.getEnd1(), ret.getEnd2()).setRelationship(ret);
    if (type1NavPropAnnotations != null) {
        np1 = np1.setAnnotations(type1NavPropAnnotations);
    }
    EdmNavigationProperty.Builder np2 = EdmNavigationProperty.newBuilder(assoc1Name)
            .setFromTo(ret.getEnd2(), ret.getEnd1()).setRelationship(ret);
    if (type2NavPropAnnotations != null) {
        np2 = np2.setAnnotations(type2NavPropAnnotations);
    }
    type1.addNavigationProperties(np1);
    // type1とtype2が同一のとき、すなわち自己参照のときは、2重でナビゲーションプロパティを登録したくない。
    if (type1 != type2) {
        type2.addNavigationProperties(np2);
    }
    return ret;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:62,代码来源:CtlSchema.java

示例3: parseEdmEntityType

import org.odata4j.edm.EdmNavigationProperty; //导入方法依赖的package包/类
/**
 * parseEdmEntityType.
 * @param reader reader
 * @param schemaNamespace schemaNamespace
 * @param schemaAlias schemaAlias
 * @param entityTypeElement entityTypeElement
 * @return EdmEntityType.Builder
 */
private EdmEntityType.Builder parseEdmEntityType(
        XMLEventReader2 reader, String schemaNamespace, String schemaAlias, StartElement2 entityTypeElement) {
    String name = entityTypeElement.getAttributeByName("Name").getValue();
    String hasStreamValue = getAttributeValueIfExists(entityTypeElement, new QName2(NS_METADATA, "HasStream"));
    Boolean hasStream = null;
    if (hasStreamValue != null) {
        hasStream = hasStreamValue.equals("true");
    }
    String baseType = getAttributeValueIfExists(entityTypeElement, "BaseType");
    String openType = getAttributeValueIfExists(entityTypeElement, "OpenType");
    String isAbstractS = getAttributeValueIfExists(entityTypeElement, "Abstract");

    List<String> keys = new ArrayList<String>();
    List<EdmProperty.Builder> edmProperties = new ArrayList<EdmProperty.Builder>();
    List<EdmNavigationProperty.Builder> edmNavigationProperties = new ArrayList<EdmNavigationProperty.Builder>();

    while (reader.hasNext()) {
        XMLEvent2 event = reader.nextEvent();
        if (event.isStartElement()) {
            StartElement2 stElem = event.asStartElement();
            log.debug("tagName: " + stElem.getName());
            log.debug("Nullable(API): " + stElem.getAttributeByName("Nullable"));
        }

        if (isStartElement(event, EDM2006_PROPERTYREF,
                EDM2007_PROPERTYREF, EDM2008_PROPERTYREF, EDM2009_PROPERTYREF)) {
            keys.add(event.asStartElement().getAttributeByName("Name").getValue());
        }

        if (isStartElement(event, EDM2006_PROPERTY, EDM2007_PROPERTY, EDM2008_PROPERTY, EDM2009_PROPERTY)) {
            edmProperties.add(parseEdmProperty(event));
        }

        if (isStartElement(event, EDM2006_NAVIGATIONPROPERTY,
                EDM2007_NAVIGATIONPROPERTY, EDM2008_NAVIGATIONPROPERTY, EDM2009_NAVIGATIONPROPERTY)) {
            String associationName = event.asStartElement().getAttributeByName("Name").getValue();
            String relationshipName = event.asStartElement().getAttributeByName("Relationship").getValue();
            String fromRoleName = event.asStartElement().getAttributeByName("FromRole").getValue();
            String toRoleName = event.asStartElement().getAttributeByName("ToRole").getValue();

            edmNavigationProperties.add(EdmNavigationProperty.newBuilder(associationName)
                    .setRelationshipName(relationshipName).setFromToName(fromRoleName, toRoleName));

        }

        if (isEndElement(event, entityTypeElement.getName())) {
            Boolean isAbstractVal = null;
            if (isAbstractS != null) {
                isAbstractVal = "true".equals(isAbstractS);
            }
            EdmEntityType.Builder builder = EdmEntityType.newBuilder()
                    .setNamespace(schemaNamespace)
                    .setAlias(schemaAlias)
                    .setName(name)
                    .setHasStream(hasStream)
                    .addKeys(keys)
                    .addProperties(edmProperties)
                    .addNavigationProperties(edmNavigationProperties)
                    .setBaseType(baseType)
                    .setIsAbstract(isAbstractVal);
            if (openType != null) {
                builder.setAnnotations(CtlSchema.OPENTYPE);
            }
            return builder;
        }
    }

    throw new UnsupportedOperationException();
}
 
开发者ID:personium,项目名称:personium-core,代码行数:78,代码来源:PersoniumEdmxFormatParser.java

示例4: parseEdmEntityType

import org.odata4j.edm.EdmNavigationProperty; //导入方法依赖的package包/类
private EdmEntityType.Builder parseEdmEntityType(XMLEventReader2 reader, String schemaNamespace, String schemaAlias, StartElement2 entityTypeElement) {
  String name = entityTypeElement.getAttributeByName("Name").getValue();
  String hasStreamValue = getAttributeValueIfExists(entityTypeElement, new QName2(NS_METADATA, "HasStream"));
  Boolean hasStream = hasStreamValue == null ? null : hasStreamValue.equals("true");
  String baseType = getAttributeValueIfExists(entityTypeElement, "BaseType");
  String isAbstractS = getAttributeValueIfExists(entityTypeElement, "Abstract");
  String openTypeValue = getAttributeValueIfExists(entityTypeElement, "OpenType");
  Boolean openType = openTypeValue == null ? null : openTypeValue.equals("true");

  List<String> keys = new ArrayList<String>();
  List<EdmProperty.Builder> edmProperties = new ArrayList<EdmProperty.Builder>();
  List<EdmNavigationProperty.Builder> edmNavigationProperties = new ArrayList<EdmNavigationProperty.Builder>();
  List<EdmAnnotation<?>> annotElements = new ArrayList<EdmAnnotation<?>>();

  while (reader.hasNext()) {
    XMLEvent2 event = reader.nextEvent();
    if (event.isStartElement()) {
      if (isElement(event, EDM2006_PROPERTYREF, EDM2007_PROPERTYREF, EDM2008_1_PROPERTYREF, EDM2008_9_PROPERTYREF, EDM2009_8_PROPERTYREF, EDM2009_11_PROPERTYREF)) {
        keys.add(event.asStartElement().getAttributeByName("Name").getValue());
      }
      else if (isElement(event, EDM2006_PROPERTY, EDM2007_PROPERTY, EDM2008_1_PROPERTY, EDM2008_9_PROPERTY, EDM2009_8_PROPERTY, EDM2009_11_PROPERTY)) {
        edmProperties.add(parseEdmProperty(reader, event));
      }
      else if (isElement(event, EDM2006_NAVIGATIONPROPERTY, EDM2007_NAVIGATIONPROPERTY, EDM2008_1_NAVIGATIONPROPERTY, EDM2008_9_NAVIGATIONPROPERTY, EDM2009_8_NAVIGATIONPROPERTY, EDM2009_11_NAVIGATIONPROPERTY)) {
        edmNavigationProperties.add(parseEdmNavigationProperty(reader, event));

      } else {
        EdmAnnotation<?> anElement = getAnnotationElements(event, reader);
        if (anElement != null) {
          annotElements.add(anElement);
        }
      }
    }

    if (isEndElement(event, entityTypeElement.getName())) {
      return EdmEntityType.newBuilder()
          .setNamespace(schemaNamespace)
          .setAlias(schemaAlias)
          .setName(name)
          .setHasStream(hasStream)
          .setOpenType(openType)
          .addKeys(keys)
          .addProperties(edmProperties)
          .addNavigationProperties(edmNavigationProperties)
          .setBaseType(baseType)
          .setIsAbstract(isAbstractS == null ? null : "true".equals(isAbstractS))
          .setAnnotations(getAnnotations(entityTypeElement))
          .setAnnotationElements(annotElements);
    }
  }

  throw new UnsupportedOperationException();
}
 
开发者ID:teiid,项目名称:oreva,代码行数:54,代码来源:EdmxFormatParser.java

示例5: generateToOneNavProperties

import org.odata4j.edm.EdmNavigationProperty; //导入方法依赖的package包/类
protected void generateToOneNavProperties(
    List<EdmAssociation.Builder> associations,
    List<EdmAssociationSet.Builder> associationSets,
    Map<String, EdmEntityType.Builder> entityTypesByName,
    Map<String, EdmEntitySet.Builder> entitySetByName,
    Map<Class<?>, String> entityNameByClass,
    String entityTypeName,
    InMemoryEntityInfo<?> ei) {

  Iterable<String> propertyNames = this.flatten ? ei.properties.getPropertyNames() : ei.properties.getDeclaredPropertyNames();
  for (String assocProp : propertyNames) {

    EdmEntityType.Builder eet1 = entityTypesByName.get(entityTypeName);
    Class<?> clazz2 = ei.properties.getPropertyType(assocProp);
    String entitySetName2 = entityNameByClass.get(clazz2);
    InMemoryEntityInfo<?> ei2 = entitySetName2 == null ? null : eis.get(entitySetName2);

    if (log.isLoggable(Level.FINE)) {
      log.log(Level.FINE, "genToOnNavProp {0} - {1}({2}) eetName2: {3}", new Object[] { entityTypeName, assocProp, clazz2, entitySetName2 });
    }

    if (eet1.findProperty(assocProp) != null || ei2 == null)
      continue;

    EdmEntityType.Builder eet2 = entityTypesByName.get(ei2.entityTypeName);

    EdmMultiplicity m1 = EdmMultiplicity.MANY;
    EdmMultiplicity m2 = EdmMultiplicity.ONE;

    String assocName = String.format("FK_%s_%s", eet1.getName(), eet2.getName());
    EdmAssociationEnd.Builder assocEnd1 = EdmAssociationEnd.newBuilder().setRole(eet1.getName())
        .setType(eet1).setMultiplicity(m1);
    String assocEnd2Name = eet2.getName();
    if (assocEnd2Name.equals(eet1.getName()))
      assocEnd2Name = assocEnd2Name + "1";

    EdmAssociationEnd.Builder assocEnd2 = EdmAssociationEnd.newBuilder().setRole(assocEnd2Name).setType(eet2).setMultiplicity(m2);
    EdmAssociation.Builder assoc = EdmAssociation.newBuilder().setNamespace(namespace).setName(assocName).setEnds(assocEnd1, assocEnd2);

    associations.add(assoc);

    EdmEntitySet.Builder ees1 = entitySetByName.get(eet1.getName());
    EdmEntitySet.Builder ees2 = entitySetByName.get(eet2.getName());
    if (ees1 == null) {
      // entity set name different than entity type name.
      ees1 = getEntitySetForEntityTypeName(eet1.getName());
    }
    if (ees2 == null) {
      // entity set name different than entity type name.
      ees2 = getEntitySetForEntityTypeName(eet2.getName());
    }

    EdmAssociationSet.Builder eas = EdmAssociationSet.newBuilder().setName(assocName).setAssociation(assoc).setEnds(
        EdmAssociationSetEnd.newBuilder().setRole(assocEnd1).setEntitySet(ees1),
        EdmAssociationSetEnd.newBuilder().setRole(assocEnd2).setEntitySet(ees2));

    associationSets.add(eas);

    EdmNavigationProperty.Builder np = EdmNavigationProperty.newBuilder(assocProp)
        .setRelationship(assoc).setFromTo(assoc.getEnd1(), assoc.getEnd2());

    eet1.addNavigationProperties(np);
  }
}
 
开发者ID:teiid,项目名称:oreva,代码行数:65,代码来源:InMemoryEdmGenerator.java


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