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


Java EdmNavigationProperty类代码示例

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


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

示例1: forEdmNavigationProperty

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
/**
 * @param navProp EdmNavigationProperty
 * @return Cardinalityの定数 (MANY_MANY等)
 */
public static int forEdmNavigationProperty(EdmNavigationProperty navProp) {
    EdmMultiplicity fromM = navProp.getFromRole().getMultiplicity();
    EdmMultiplicity toM = navProp.getToRole().getMultiplicity();
    if (EdmMultiplicity.MANY.equals(fromM)) {
        if (EdmMultiplicity.MANY.equals(toM)) {
            // NN
            return MANY_MANY;
        } else {
            // N1
            return MANY_ONE;
        }
    } else {
        if (EdmMultiplicity.MANY.equals(toM)) {
            // 1N
            return ONE_MANY;
        } else {
            // 11
            return ONE_ONE;
        }
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:26,代码来源:ODataUtils.java

示例2: validateLinkForNavigationPropertyContext

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
/**
 * リンク元・先のデータチェックや、既にリンクが作成済みかなどの、データ登録の前提条件をチェックする.
 * @param navigationPropertyContext NP経由登録用のコンテキスト
 */
private void validateLinkForNavigationPropertyContext(NavigationPropertyBulkContext navigationPropertyContext) {
    OEntityId sourceEntity = navigationPropertyContext.getSrcEntityId();
    OEntity targetEntity = navigationPropertyContext.getOEntityWrapper();

    String targetNavProp = navigationPropertyContext.getTgtNavProp();
    String srcSetName = sourceEntity.getEntitySetName();
    EdmNavigationProperty srcNavProp = getEdmNavigationProperty(srcSetName, targetNavProp);

    if (srcNavProp == null) {
        throw PersoniumCoreException.OData.NO_SUCH_ASSOCIATION;
    }

    EntitySetDocHandler src = navigationPropertyContext.getSourceDocHandler();
    // データが存在しない場合は404
    if (src == null) {
        throw PersoniumCoreException.OData.NOT_FOUND;
    }

    // 1:1の関連は存在し得ないので、AssociationEnd - AssociationEndの$linksで1:1の登録をしようとした場合はエラーとする
    String targetEntitySetName = targetEntity.getEntitySetName();
    checkAssociationEndMultiplicity(targetNavProp, targetEntity, targetEntitySetName, src);

    // $linksの登録済みチェック
    checkExistsLink(sourceEntity, srcNavProp, src, targetEntity);
}
 
开发者ID:personium,项目名称:personium-core,代码行数:30,代码来源:EsODataProducer.java

示例3: checkUpperLimitRecord

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
/**
 * $linksの登録可能な上限値を超えて登録をしようとしているかをチェックする.
 * @param srcNavProp ソース側のEdmNavigationProperty
 * @param sourceDocHandler ソース側のDocHandler
 * @param targetEntitySetName ターゲット側のEntitySet名
 */
private void checkUpperLimitRecord(
        EdmNavigationProperty srcNavProp,
        EntitySetDocHandler sourceDocHandler,
        String targetEntitySetName) {
    // 関連がN:N以外の場合は、上限値制限なし
    if (!isAssociationOfNToN(srcNavProp.getRelationship())) {
        return;
    }

    // ユーザデータの$links取得の場合、targetのEntityTypeの_idを取得する
    String targetEntityTypeId = null;
    if (sourceDocHandler.getType().equals(UserDataODataProducer.USER_ODATA_NAMESPACE)) {
        targetEntityTypeId = getEntityTypeId(targetEntitySetName);
    }

    // 登録済み$links
    long count = LinkDocHandler.getNtoNCount(this.getAccessorForLink(), sourceDocHandler, targetEntitySetName,
            targetEntityTypeId);
    log.info("Registered links count: [" + count + "]");

    if (count >= (long) PersoniumUnitConfig.getLinksNtoNMaxSize()) {
        throw PersoniumCoreException.OData.LINK_UPPER_LIMIT_RECORD_EXEED;
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:31,代码来源:EsODataProducer.java

示例4: setNavigationPropertyLinkType

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
/**
 * 一括登録用のコンテキストにリンクタイプをセットする.
 * @param navigationPropertyContext 一括登録のコンテキスト
 */
private void setNavigationPropertyLinkType(
        NavigationPropertyBulkContext navigationPropertyContext) {
    OEntityId sourceOEntity = navigationPropertyContext.getSrcEntityId();
    String srcSetName = sourceOEntity.getEntitySetName();
    String targetNavProp = navigationPropertyContext.getTgtNavProp();
    EdmNavigationProperty srcNavProp = getEdmNavigationProperty(srcSetName, targetNavProp);

    EdmAssociation assoc = srcNavProp.getRelationship();
    EdmMultiplicity multiplicity1 = assoc.getEnd1().getMultiplicity();
    EdmMultiplicity multiplicity2 = assoc.getEnd2().getMultiplicity();

    if (multiplicity1 == EdmMultiplicity.MANY && multiplicity2 == EdmMultiplicity.MANY) {
        navigationPropertyContext.setLinkType(NavigationPropertyLinkType.manyToMany);
    } else if ((multiplicity1 == EdmMultiplicity.ONE || multiplicity1 == EdmMultiplicity.ZERO_TO_ONE)
            && (multiplicity2 == EdmMultiplicity.ONE || multiplicity2 == EdmMultiplicity.ZERO_TO_ONE)) {
        navigationPropertyContext.setLinkType(NavigationPropertyLinkType.oneToOne);
    } else {
        String multiplicityOneEntitySetName = getOneAssociationEnd(assoc).getType().getName();
        if (sourceOEntity.getEntitySetName().equals(multiplicityOneEntitySetName)) {
            navigationPropertyContext.setLinkType(NavigationPropertyLinkType.oneToMany);
        } else {
            navigationPropertyContext.setLinkType(NavigationPropertyLinkType.manyToOne);
        }
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:30,代码来源:EsODataProducer.java

示例5: getEntityTypeListForLinkTable

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
/**
 * Linkテーブル検索対象のエンティティタイプ一覧を返却する.
 * @return Linkテーブル検索対象のエンティティタイプ一覧
 */
private List<String> getEntityTypeListForLinkTable() {
    List<String> entityTypeListForLinkTable = new ArrayList<String>();
    for (String expandEntity : this.navigationPropertyList) {
        // Multiplicityを取得
        EdmNavigationProperty edmNavProp = this.edmBaseEntityType.findNavigationProperty(expandEntity);
        int cardinality = ODataUtils.Cardinality.forEdmNavigationProperty(edmNavProp);

        // N:Nの場合はLinkテーブル検索対象となるため、エンティティタイプ名をリストに追加する
        if (ODataUtils.Cardinality.MANY_MANY == cardinality) {
            String entityTypeName = edmNavProp.getToRole().getType().getName();
            entityTypeListForLinkTable.add(entityTypeName);
        }
    }
    return entityTypeListForLinkTable;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:20,代码来源:ExpandEntitiesMapCreator.java

示例6: ODataPropertyResource

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
/**
 * コンストラクタ.
 * @param entityResource 親リソース
 * @param targetNavProp Navigation Property
 */
public ODataPropertyResource(
        final ODataEntityResource entityResource,
        final String targetNavProp) {
    this.targetNavProp = targetNavProp;
    this.sourceOData = entityResource.getOdataResource();
    this.sourceEntityId = entityResource.getOEntityId();
    setOdataProducer(entityResource.getOdataProducer());
    this.accessContext = entityResource.getAccessContext();
    this.odataResource = entityResource.getOdataResource();
    // Navigationプロパティのスキーマ上の存在確認
    EdmEntitySet eSet = getOdataProducer().getMetadata().findEdmEntitySet(this.sourceEntityId.getEntitySetName());
    EdmNavigationProperty enp = eSet.getType().findNavigationProperty(this.targetNavProp);
    if (enp == null) {
        throw PersoniumCoreException.OData.NOT_SUCH_NAVPROP;
    }
    // TargetのEntityKey, EdmEntitySetを準備
    EdmEntityType tgtType = enp.getToRole().getType();
    this.targetEntitySet = getOdataProducer().getMetadata().findEdmEntitySet(tgtType.getName());
}
 
开发者ID:personium,项目名称:personium-core,代码行数:25,代码来源:ODataPropertyResource.java

示例7: inline

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
protected <T> T inline(T rt, String navProperty, OEntity... entities) {
  EdmEntitySet entitySet = metadata.getEdmEntitySet(entitySetName);
  EdmNavigationProperty navProp = entitySet.getType().findNavigationProperty(navProperty);
  if (navProp == null)
    throw new IllegalArgumentException("unknown navigation property " + navProperty);

  // TODO get rid of XmlFormatWriter
  String rel = XmlFormatWriter.related + navProperty;
  String href = entitySetName + "/" + navProperty;
  if (navProp.getToRole().getMultiplicity() == EdmMultiplicity.MANY) {
    links.add(OLinks.relatedEntitiesInline(rel, navProperty, href, Arrays.asList(entities)));
  } else {
    if (entities.length > 1)
      throw new IllegalArgumentException("only one entity is allowed for this navigation property " + navProperty);

    links.add(OLinks.relatedEntityInline(rel, navProperty, href,
        entities.length > 0 ? entities[0] : null));
  }

  return rt;
}
 
开发者ID:teiid,项目名称:oreva,代码行数:22,代码来源:AbstractConsumerEntityPayloadRequest.java

示例8: getNavProperty

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
/**
 * Gets the entity(s) on the target end of a NavigationProperty.
 *
 * @param navProp  the navigation property
 * @param rc  the request context
 * @return a BaseResponse with either a single Entity (can be null) or a set of entities.
 */
protected BaseResponse getNavProperty(EdmNavigationProperty navProp, RequestContext rc) {

  // First, get the source POJO.
  Object obj = getEntityPojo(rc);
  Iterable relatedPojos = this.getRelatedPojos(navProp, obj, this.findEntityInfoForClass(obj.getClass()));

  EdmEntitySet targetEntitySet = findEntitySetForNavProperty(navProp);

  if (navProp.getToRole().getMultiplicity() == EdmMultiplicity.MANY) {
    // apply filter, orderby, etc.
    return getEntitiesResponse(rc, targetEntitySet, Enumerable.create(relatedPojos), eis.get(targetEntitySet.getName()).getPropertyModel());
  } else {
    return Responses.entity(this.toOEntity(targetEntitySet, relatedPojos.iterator().next(), rc.getPathHelper()));
  }
}
 
开发者ID:teiid,项目名称:oreva,代码行数:23,代码来源:InMemoryProducer.java

示例9: findMultiPoint

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
/**
 * 1-0:Nの削除処理時にN側を検索処理を行う.
 * @param np EdmNavigationProperty
 * @param entityKey entityKey
 * @return 存在する場合true
 */
public boolean findMultiPoint(final EdmNavigationProperty np, final OEntityKey entityKey) {
    EdmAssociationEnd from = np.getFromRole();
    EdmAssociationEnd to = np.getToRole();
    if ((EdmMultiplicity.ONE.equals(from.getMultiplicity())
            || EdmMultiplicity.ZERO_TO_ONE.equals(from.getMultiplicity()))
            && EdmMultiplicity.MANY.equals(to.getMultiplicity())) {
        // 検索して0件であることを確認する;
        CountResponse cr = getNavPropertyCount(from.getType().getName(), entityKey, to.getType().getName(),
                new EntityQueryInfo.Builder().build());
        return cr.getCount() > 0;
    }
    return false;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:20,代码来源:EsODataProducer.java

示例10: createLink

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
/**
 * Creates a link between two entities.
 * @param sourceEntity an entity with at least one navigation property
 * @param targetNavProp the navigation property
 * @param targetEntity the link target entity
 * @see <a href="http://www.odata.org/developers/protocols/operations#CreatingLinksbetweenEntries">[odata.org]
 *      Creating Links between Entries</a>
 */
@Override
public final void createLink(OEntityId sourceEntity, String targetNavProp, OEntityId targetEntity) {
    String srcSetName = sourceEntity.getEntitySetName();

    EdmNavigationProperty srcNavProp = getEdmNavigationProperty(srcSetName, targetNavProp);
    if (srcNavProp == null) {
        throw PersoniumCoreException.OData.NO_SUCH_ASSOCIATION;
    }
    // n:1かn:nの切り分けを行う
    EdmAssociation assoc = srcNavProp.getRelationship();
    // ユニーク性チェックのためまずロックを行う
    // OData 空間全体をlockする(将来的に必要があればentitySetNameでロック)
    Lock lock = this.lock();
    try {
        EntitySetDocHandler src = this.retrieveWithKey(sourceEntity);
        // データが存在しない場合は404
        if (src == null) {
            throw PersoniumCoreException.OData.NOT_FOUND;
        }
        EntitySetDocHandler tgt = this.retrieveWithKey(targetEntity);
        // ターゲットが存在しない場合は400
        if (tgt == null) {
            throw PersoniumCoreException.OData.REQUEST_FIELD_FORMAT_ERROR.params("uri");
        }
        createLinks(sourceEntity, srcNavProp, assoc, src, tgt);
    } finally {
        log.debug("unlock");
        lock.release();
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:39,代码来源:EsODataProducer.java

示例11: getEdmNavigationProperty

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
/**
 * NavigationProeprtyのEdm(スキーマ)を取得する.
 * @param entitySetName 取得対象のEntitySet名
 * @param navigationPropertyName 取得対象のNavigationProperty名
 * @return NavigationProeprtyのEdm(スキーマ)
 */
private EdmNavigationProperty getEdmNavigationProperty(String entitySetName, String navigationPropertyName) {
    EdmEntitySet srcSet = this.getMetadata().findEdmEntitySet(entitySetName);
    EdmEntityType srcType = srcSet.getType();
    EdmNavigationProperty srcNavProp = srcType.findNavigationProperty(navigationPropertyName);
    return srcNavProp;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:13,代码来源:EsODataProducer.java

示例12: createLinks

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
/**
 * N:NのLinksを生成.
 * @param sourceEntity リクエストURLにて指定されたEntity
 * @param targetEntity リクエストBODYにて指定されたEntity
 */
protected void createLinks(OEntityId sourceEntity, OEntityId targetEntity) {
    EntitySetDocHandler src = this.retrieveWithKey(sourceEntity);
    // データが存在しない場合は404
    if (src == null) {
        throw PersoniumCoreException.OData.NOT_FOUND;
    }
    EntitySetDocHandler tgt = this.retrieveWithKey(targetEntity);
    // ターゲットが存在しない場合は400
    if (tgt == null) {
        throw PersoniumCoreException.OData.REQUEST_FIELD_FORMAT_ERROR.params("uri");
    }
    // NNLink情報の ES保存時の一意キー作成
    LinkDocHandler docHandler = this.getLinkDocHandler(src, tgt);
    // LINKを扱うアクセサを取る
    ODataLinkAccessor linkAccessor = this.getAccessorForLink();

    // $linksの登録
    checkExistsLinkForNtoN(linkAccessor, docHandler);

    String sourceEntitySetName = sourceEntity.getEntitySetName();
    String targetEntitySetName = targetEntity.getEntitySetName();
    EdmNavigationProperty srcNavProp = getEdmNavigationProperty(sourceEntitySetName, "_" + targetEntitySetName);
    // $links上限値チェック
    // リンク元
    checkUpperLimitRecord(srcNavProp, src, targetEntitySetName);
    // リンク先
    checkUpperLimitRecord(srcNavProp, tgt, sourceEntitySetName);

    createLinkForNtoN(linkAccessor, docHandler);
}
 
开发者ID:personium,项目名称:personium-core,代码行数:36,代码来源:EsODataProducer.java

示例13: checkExistsLinkForOnetoOne

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
private void checkExistsLinkForOnetoOne(final EntitySetDocHandler source,
        final EntitySetDocHandler target,
        EdmNavigationProperty srcNavProp) {
    // 既に同一NavigationPropetiesにlinksが登録されている場合は409とする
    String toLinksKey = getLinkskey(srcNavProp.getToRole().getType().getName());
    String fromLinksKey = getLinkskey(srcNavProp.getFromRole().getType().getName());
    Map<String, Object> sourceLinks = source.getManyToOnelinkId();
    if (sourceLinks.get(toLinksKey) != null) {
        throw PersoniumCoreException.OData.CONFLICT_LINKS;
    } else if (target != null && target.getManyToOnelinkId().get(fromLinksKey) != null) {
        throw PersoniumCoreException.OData.CONFLICT_LINKS;
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:14,代码来源:EsODataProducer.java

示例14: createLinkForOnetoOne

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
/**
 * 1:1のlinksを生成.
 * @param sourceEntity リクエストURLにて指定されたEntity
 * @param targetEntity リクエストBODYにて指定されたEntity
 * @param srcNavProp ナビゲーションプロパティ
 * @return バージョン情報
 */
private long createLinkForOnetoOne(final EntitySetDocHandler source,
        final EntitySetDocHandler target,
        EdmNavigationProperty srcNavProp) {
    String toLinksKey = getLinkskey(srcNavProp.getToRole().getType().getName());
    String fromLinksKey = getLinkskey(srcNavProp.getFromRole().getType().getName());
    Map<String, Object> sourceLinks = source.getManyToOnelinkId();
    Map<String, Object> targetLinks = target.getManyToOnelinkId();

    // link情報を更新する
    sourceLinks.put(toLinksKey, target.getId());
    source.setManyToOnelinkId(sourceLinks);

    // Aliasをプロパティ名に変換する
    source.convertAliasToName(getMetadata());
    updateLink(source, fromLinksKey);

    // NP経由でPropetyを作成した場合、バージョンが更新されるので、バージョンを取得する
    targetLinks.put(fromLinksKey, source.getId());
    target.setManyToOnelinkId(targetLinks);

    // Aliasをプロパティ名に変換する
    target.convertAliasToName(getMetadata());

    long version = updateLink(target, toLinksKey);
    return version;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:34,代码来源:EsODataProducer.java

示例15: deleteLinks

import org.odata4j.edm.EdmNavigationProperty; //导入依赖的package包/类
/**
 * Delete N:N links.
 * @param navigationProperty EdmNavigationProperty
 * @param fromDocHandler dochandler
 */
private void deleteLinks(EdmNavigationProperty navigationProperty, EntitySetDocHandler fromDocHandler) {
    EdmAssociationEnd from = navigationProperty.getFromRole();
    EdmAssociationEnd to = navigationProperty.getToRole();
    if (EdmMultiplicity.MANY.equals(from.getMultiplicity())
            && EdmMultiplicity.MANY.equals(to.getMultiplicity())) {
        String toTypeName = to.getType().getName();
        // In the case of links of user data, get _id of EntityType.
        String toEntityTypeId = null;
        if (UserDataODataProducer.USER_ODATA_NAMESPACE.equals(fromDocHandler.getType())) {
            toEntityTypeId = getEntityTypeId(toTypeName);
        }
        // Get links up to the registered number limit.
        EntitySetAccessor toEsType = getAccessorForEntitySet(toTypeName);
        QueryInfo queryInfo = QueryInfo.newBuilder().setTop(PersoniumUnitConfig.getLinksNtoNMaxSize())
                .setInlineCount(InlineCount.NONE).build();
        List<String> idvals = LinkDocHandler.query(this.getAccessorForLink(),
                fromDocHandler, toEsType.getType(), toEntityTypeId, queryInfo);

        PersoniumSearchHits searchHits = ODataProducerUtils.searchLinksNN(idvals, toEsType, null);
        if (searchHits == null || searchHits.getCount() == 0) {
            return;
        }
        // Delete links.
        for (PersoniumSearchHit hit : searchHits.getHits()) {
            EntitySetDocHandler toDocHandler = getDocHandler(hit, toTypeName);
            deleteLinkEntity(fromDocHandler, toDocHandler);
        }
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:35,代码来源:EsODataProducer.java


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