• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Subgraph类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addAttributeNodes

import javax.persistence.Subgraph; //导入依赖的package包/类
private static void addAttributeNodes(String fieldName, EntityGraph<?> graph) {
    int pos = fieldName.indexOf(GRAPH_DELIMETER);
    if (pos < 0) {
        graph.addAttributeNodes(fieldName);
        return;
    }

    String subgraphName = fieldName.substring(0, pos);
    Subgraph<?> subGraph = graph.addSubgraph(subgraphName);
    String nextFieldName = fieldName.substring(pos + 1);
    pos = nextFieldName.indexOf(GRAPH_DELIMETER);

    while (pos > 0) {
        subgraphName = nextFieldName.substring(0, pos);
        subGraph = graph.addSubgraph(subgraphName);
        nextFieldName = nextFieldName.substring(pos + 1);
        pos = nextFieldName.indexOf(GRAPH_DELIMETER);
    }

    subGraph.addAttributeNodes(nextFieldName);
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:22,代码来源:EntityGraphRepositoryImpl.java


示例2: startingAttribute

import javax.persistence.Subgraph; //导入依赖的package包/类
/**
 * I'm using NULL-OBJECT pattern here, for attributes that not existing in the EntityGraph,
 * a predefined NULL-ATTRIBUTE-NODE is pushed to the stack.
 *
 * and for an not existing sub graph, a predefined NULL-SUBGRAPH is pushed to the stack.
 *
 * So, whenever we're start visiting an attribute, there will be a attribute node pushed to the attribute stack,
 * and a subgraph node pushed to the graph stack.
 *
 * when we're finish visiting an attribute, these two will be poped from each stack.
 */
@Override
public boolean startingAttribute(AttributeDefinition attributeDefinition) {
	Map<String, AttributeNodeImplementor> attributeMap = attributeMapStack.peekLast();
	final String attrName = attributeDefinition.getName();
	AttributeNodeImplementor attributeNode = NON_EXIST_ATTRIBUTE_NODE;
	GraphNodeImplementor subGraphNode = NON_EXIST_SUBGRAPH_NODE;
	//the attribute is in the EntityGraph, so, let's continue
	if ( attributeMap.containsKey( attrName ) ) {
		attributeNode = attributeMap.get( attrName );
		//here we need to check if there is a subgraph (or sub key graph if it is an indexed attribute )
		Map<Class, Subgraph> subGraphs = attributeNode.getSubgraphs();
		Class javaType = attributeDefinition.getType().getReturnedClass();
		if ( !subGraphs.isEmpty() && subGraphs.containsKey( javaType ) ) {
			subGraphNode = (GraphNodeImplementor) subGraphs.get( javaType );
		}

	}
	attributeStack.addLast( attributeNode );
	graphStack.addLast( subGraphNode );
	return super.startingAttribute( attributeDefinition );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:AbstractEntityGraphVisitationStrategy.java


示例3: applyFetchPaths

import javax.persistence.Subgraph; //导入依赖的package包/类
private <T> Subgraph<Object> applyFetchPaths(EntityGraph<T> graph, MetaAttributePath fetchPath) {
	if (fetchPath.length() >= 2) {
		// ensure parent is fetched
		MetaAttributePath parentPath = fetchPath.subPath(0, fetchPath.length() - 1);
		Subgraph<Object> parentGraph = applyFetchPaths(graph, parentPath);
		return parentGraph.addSubgraph(fetchPath.toString());
	} else {
		return graph.addSubgraph(fetchPath.toString());
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:11,代码来源:EntityGraphBuilderImpl.java


示例4: startingCollectionElements

import javax.persistence.Subgraph; //导入依赖的package包/类
@Override
public void startingCollectionElements(
		final CollectionElementDefinition elementDefinition) {
	AttributeNodeImplementor attributeNode = attributeStack.peekLast();
	GraphNodeImplementor subGraphNode = NON_EXIST_SUBGRAPH_NODE;
	Map<Class, Subgraph> subGraphs = attributeNode.getSubgraphs();
	Class javaType = elementDefinition.getType().getReturnedClass();
	if ( !subGraphs.isEmpty() && subGraphs.containsKey( javaType ) ) {
		subGraphNode = (GraphNodeImplementor) subGraphs.get( javaType );
	}
	graphStack.addLast( subGraphNode );
	super.startingCollectionElements( elementDefinition );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:AbstractEntityGraphVisitationStrategy.java


示例5: startingCollectionIndex

import javax.persistence.Subgraph; //导入依赖的package包/类
@Override
public void startingCollectionIndex(final CollectionIndexDefinition indexDefinition) {
	AttributeNodeImplementor attributeNode = attributeStack.peekLast();
	GraphNodeImplementor subGraphNode = NON_EXIST_SUBGRAPH_NODE;
	Map<Class, Subgraph> subGraphs = attributeNode.getKeySubgraphs();
	Class javaType = indexDefinition.getType().getReturnedClass();
	if ( !subGraphs.isEmpty() && subGraphs.containsKey( javaType ) ) {
		subGraphNode = (GraphNodeImplementor) subGraphs.get( javaType );
	}
	graphStack.addLast( subGraphNode );
	super.startingCollectionIndex( indexDefinition );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:AbstractEntityGraphVisitationStrategy.java


示例6: applyFetchPaths

import javax.persistence.Subgraph; //导入依赖的package包/类
private Subgraph<Object> applyFetchPaths(EntityGraph<T> graph, MetaAttributePath fetchPath) {
	if (fetchPath.length() >= 2) {
		// ensure parent is fetched
		MetaAttributePath parentPath = fetchPath.subPath(0, fetchPath.length() - 1);
		Subgraph<Object> parentGraph = applyFetchPaths(graph, parentPath);
		return parentGraph.addSubgraph(fetchPath.toString());
	}
	else {
		return graph.addSubgraph(fetchPath.toString());
	}
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:12,代码来源:AbstractQueryExecutorImpl.java


示例7: buildSubgraph

import javax.persistence.Subgraph; //导入依赖的package包/类
/**
 * Builds an subgraph and connects it with the upper graph.
 * 
 * @param subgraph
 *            current subgraph without any elements (graph is already
 *            connected to upper-graph)
 * @param graphName
 *            name of the entity-graph
 * @param upperElem
 *            Element which references to the subgraph
 * @param subgraphList
 *            List with all defined subgraph-nodes
 * @param doc
 *            Document which is needed for the compilation of the xpath
 * @return a new build subgraph
 */
private Subgraph<?> buildSubgraph(final Subgraph<?> subgraph, final String graphName, final Element upperElem,
		final NodeList subgraphList, final Document doc) {

	// searches for the right subgraph
	for (int j = 0; j < subgraphList.getLength(); ++j) {
		final Element subgraphElem = (Element) subgraphList.item(j);

		if (subgraphElem.getAttribute("name").equals(upperElem.getAttribute("subgraph"))) {
			final String attributesSubgraphListString = "//named-entity-graph[@name='" + graphName
					+ "']/subgraph[@name='" + subgraphElem.getAttribute("name") + "']/named-attribute-node";

			NodeList attributesSubgraphList = null;
			try {
				attributesSubgraphList = (NodeList) xPath.compile(attributesSubgraphListString).evaluate(doc,
						XPathConstants.NODESET);
			} catch (final XPathExpressionException e) {
				LOGGER.warn("Exception in BuildEntityGraph::buildSubgraph, full stack trace follows: ", e);
			}

			// reads all attributes of the subgraph
			for (int k = 0; k < attributesSubgraphList.getLength(); ++k) {
				final Element attributeSubgraphElem = (Element) attributesSubgraphList.item(k);

				// attributes of subgraph
				if ("".equals(attributeSubgraphElem.getAttribute("subgraph"))) {
					// adds the attributes to the subgraph
					subgraph.addAttributeNodes(attributeSubgraphElem.getAttribute("name"));
				}
				// references to other subgraphs
				else {
					Subgraph<?> deeperSubgraph = null;
					deeperSubgraph = subgraph.addSubgraph(attributeSubgraphElem.getAttribute("name"));
					buildSubgraph(deeperSubgraph, graphName, attributeSubgraphElem, subgraphList, doc);
				}
			}
		}
	}
	return subgraph;
}
 
开发者ID:doubleSlashde,项目名称:jEDM,代码行数:56,代码来源:BuildEntityGraph.java


示例8: getSubgraphs

import javax.persistence.Subgraph; //导入依赖的package包/类
@Override
public Map<Class, Subgraph> getSubgraphs() {
	return Collections.emptyMap();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:AbstractEntityGraphVisitationStrategy.java


示例9: getKeySubgraphs

import javax.persistence.Subgraph; //导入依赖的package包/类
@Override
public Map<Class, Subgraph> getKeySubgraphs() {
	return Collections.emptyMap();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:AbstractEntityGraphVisitationStrategy.java


示例10: generateEntityGraphXPath

import javax.persistence.Subgraph; //导入依赖的package包/类
/**
 * Builds an entity graph from a XML file.
 * 
 * @param graphName
 *            name of the entity graph
 * @param classType
 *            entity graph with rootElement of classType
 * @return result generated entity graph with rootElement of classType - can
 *         be null if an error occurs during entity graph initialization
 */
@Override
public <T> EntityGraph<?> generateEntityGraphXPath(final EntityManager em, final String graphName,
		final Class<T> classType) {
	EntityGraph<?> graph = null;

	try {
		URL centralMappingFilePath = JEntityGraphDataMapper.class.getResource(FilePaths.CENTRAL_XML_NAME.path());
		File centralRules;

		centralRules = new File(centralMappingFilePath.toURI());

		final DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
		final DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
		final Document doc = dBuilder.parse(centralRules);
		doc.getDocumentElement().normalize();

		xPath = XPathFactory.newInstance().newXPath();

		// list of attribute-nodes from the root class of the selected
		// entity graph
		final String attributeRootNodeListString = "//named-entity-graph[@name='" + graphName
				+ "']/named-attribute-node";
		final NodeList attributeRootNodeList = (NodeList) xPath.compile(attributeRootNodeListString).evaluate(doc,
				XPathConstants.NODESET);

		// list of all subgraphs
		final String subgraphListString = "//named-entity-graph[@name='" + graphName + "']/subgraph";
		final NodeList subgraphList = (NodeList) xPath.compile(subgraphListString).evaluate(doc,
				XPathConstants.NODESET);

		// create EntityGraph
		graph = em.createEntityGraph(classType);

		// reads all named-attribute-nodes below the named-entity-graph
		for (int i = 0; i < attributeRootNodeList.getLength(); ++i) {
			final Element nodeElem = (Element) attributeRootNodeList.item(i);

			// adds the attributes to the graph
			if ("".equals(nodeElem.getAttribute("subgraph"))) {
				graph.addAttributeNodes(nodeElem.getAttribute("name"));
			}
			// reference to a subgraph
			else {
				// create subgraph with a reference to the upper class
				final Subgraph<?> subgraph = graph.addSubgraph(nodeElem.getAttribute("name"));
				buildSubgraph(subgraph, graphName, nodeElem, subgraphList, doc);
			}
		}
	} catch (XPathExpressionException | ParserConfigurationException | SAXException | IOException
			| URISyntaxException e) {
		LOGGER.warn("Exception in BuildEntityGraph::generateEntityGraphXPath, full stack trace follows: ", e);
	}
	return graph;
}
 
开发者ID:doubleSlashde,项目名称:jEDM,代码行数:65,代码来源:BuildEntityGraph.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IDetailsPage类代码示例发布时间:2022-05-23
下一篇:
Java QualifiedName类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap