本文整理了Java中org.zstack.header.search.Inventory.mappingVOClass()
方法的一些代码示例,展示了Inventory.mappingVOClass()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Inventory.mappingVOClass()
方法的具体详情如下:
包路径:org.zstack.header.search.Inventory
类名称:Inventory
方法名:mappingVOClass
暂无
代码示例来源:origin: zstackio/zstack
public static Class getEntityClassFromInventoryClass(Class invClz) {
Inventory at = (Inventory) invClz.getAnnotation(Inventory.class);
return at.mappingVOClass();
}
代码示例来源:origin: zstackio/zstack
private String createTagPatternSQL(Class invClz, String fieldName, boolean nestedQuery) {
ZQLMetadata.InventoryMetadata src = ZQLMetadata.getInventoryMetadataByName(invClz.getName());
String primaryKey = EntityMetadata.getPrimaryKeyField(src.inventoryAnnotation.mappingVOClass()).getName();
boolean reserve = TAG_FALSE_OP.containsKey(operator);
String op = reserve ? TAG_FALSE_OP.get(operator) : operator;
String subCondition = String.format("pattern.uuid %s ", op + (value == null ? "" : value));
String filterResourceUuidSQL = String.format("SELECT utag.resourceUuid FROM UserTagVO utag, TagPatternVO pattern" +
" WHERE %s and utag.tagPatternUuid = pattern.uuid", subCondition);
String weather_not_in = reserve ? "NOT" : "";
if (nestedQuery) {
return String.format("(SELECT %s.%s FROM %s %s WHERE %s.%s %s IN (%s))",
src.simpleInventoryName(), primaryKey, src.inventoryAnnotation.mappingVOClass().getSimpleName(), src.simpleInventoryName(),
src.simpleInventoryName(), primaryKey, weather_not_in, filterResourceUuidSQL);
} else {
return String.format("(%s.%s %s IN (%s))",
src.simpleInventoryName(), primaryKey, weather_not_in, filterResourceUuidSQL);
}
}
代码示例来源:origin: zstackio/zstack
private void constructFieldMapping() {
Class selfVoClass = inventoryAnnotation.mappingVOClass();
Map<String, Field> inventoryFieldMap = getAllFieldMap(selfInventoryClass);
for (Field it : getAllFieldMap(selfVoClass).values()) {
try {
Class voFieldType = it.getType();
Field inventoryField = inventoryFieldMap.get(it.getName());
if (inventoryField == null){
continue;
}
Class inventoryFieldType = inventoryField.getType();
if (!inventoryFieldType.equals(voFieldType)) {
typeMappingMap.put(it.getName(), new FieldTypeMapping(inventoryFieldType, voFieldType));
}
} catch (Exception e) {
throw new CloudRuntimeException(e);
}
}
}
代码示例来源:origin: zstackio/zstack
&& Modifier.isStatic(method.getModifiers())
&& method.getParameterTypes().length == 1
&& method.getParameterTypes()[0].isAssignableFrom(at.mappingVOClass())) {
m.valueOf = method;
} else if (m.valueOfCollection == null && method.getName().equals(collectionMethodName)
inventoryMetadata.put(at.mappingVOClass(), m);
});
代码示例来源:origin: zstackio/zstack
String toSQL() {
ZQLMetadata.InventoryMetadata metadata = ZQLMetadata.getInventoryMetadataByName(inventoryClass.getName());
if (metadata == null) {
throw new CloudRuntimeException(String.format("cannot find InventoryMetadata for class[%s]", inventoryClass));
}
Field primaryKey = EntityMetadata.getPrimaryKeyField(metadata.inventoryAnnotation.mappingVOClass());
Class mappingInventoryClass = annotation.mappingClass();
ZQLMetadata.InventoryMetadata mappingInventoryMetadata = ZQLMetadata.getInventoryMetadataByName(mappingInventoryClass.getName());
String mappingEntityName = mappingInventoryClass.getSimpleName();
return String.format("%s.%s IN (SELECT %s.%s FROM %s %s WHERE %s.%s %%s %%s)",
inventoryClass.getSimpleName(), primaryKey.getName(), mappingEntityName,
annotation.joinColumn().name(), mappingInventoryMetadata.inventoryAnnotation.mappingVOClass().getSimpleName(),
mappingEntityName, mappingEntityName, annotation.joinColumn().referencedColumnName());
}
}
代码示例来源:origin: zstackio/zstack
private void populateInventoryIndexer() throws URISyntaxException, ClassNotFoundException, NoSuchMethodException {
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
scanner.addIncludeFilter(new AnnotationTypeFilter(Inventory.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
for (String pkg : getBasePkgNames()) {
for (BeanDefinition bd : scanner.findCandidateComponents(pkg)) {
Class<?> inventoryClass = Class.forName(bd.getBeanClassName());
Inventory invat = inventoryClass.getAnnotation(Inventory.class);
if (!triggerVOs.contains(invat.mappingVOClass())) {
String err = String.format("Inventory[%s]'s mapping VO class[%s] is not annotated by @TriggerIndex", inventoryClass.getName(), invat
.mappingVOClass().getName());
throw new IllegalArgumentException(err);
}
String mappingClassSimpleName = invat.mappingVOClass().getSimpleName();
IndexerInfo info = voClassToIndexerMapping.get(mappingClassSimpleName);
if (info == null) {
String invName = inventoryClass.getSimpleName();
info = new IndexerInfo();
info.url = String.format("%s/%s/%s", elasticSearchBaseUrl, invName.toLowerCase(), invName);
info.inventoryClass = inventoryClass;
info.inventoryName = invName;
info.mappingVOClass = invat.mappingVOClass();
info.valueOfMethod = getValueOfMethodOfInventoryClass(inventoryClass);
info.entityIdField = getEntityIdFieldFromClass(info.mappingVOClass);
info.entityIdField.setAccessible(true);
voClassToIndexerMapping.put(mappingClassSimpleName, info);
}
}
}
}
代码示例来源:origin: zstackio/zstack
public AbstractQueryVisitorPlugin(ASTNode.Query node) {
super(node);
inventory = ZQLMetadata.findInventoryMetadata(node.getTarget().getEntity());
entityAlias = inventory.simpleInventoryName();
entityVOName = inventory.inventoryAnnotation.mappingVOClass().getSimpleName();
}
代码示例来源:origin: zstackio/zstack
@Override
public String visit(ASTNode.SubQuery node) {
ZQLMetadata.InventoryMetadata inventory = ZQLMetadata.findInventoryMetadata(node.getTarget().getEntity());
ZQLContext.pushQueryTargetInventoryName(inventory.fullInventoryName());
String fieldName = node.getTarget().getFields() == null || node.getTarget().getFields().isEmpty() ? "" : node.getTarget().getFields().get(0);
if (fieldName != "") {
inventory.errorIfNoField(fieldName);
}
String entityAlias = inventory.simpleInventoryName();
String queryTarget = fieldName.equals("") ? entityAlias : String.format("%s.%s", inventory.simpleInventoryName(), fieldName);
String entityVOName = inventory.inventoryAnnotation.mappingVOClass().getSimpleName();
List<String> clauses = new ArrayList<>();
clauses.add(String.format("SELECT %s FROM %s %s", queryTarget, entityVOName, entityAlias));
String condition = makeConditions(node);
if (!condition.equals("")) {
clauses.add("WHERE");
clauses.add(condition);
}
ZQLContext.popQueryTargetInventoryName();
return String.format("(%s)", StringUtils.join(clauses, " "));
}
}
代码示例来源:origin: zstackio/zstack
EntityInfo(Class invClass) throws NoSuchMethodException {
inventoryAnnotation = (Inventory) invClass.getAnnotation(Inventory.class);
entityClass = inventoryAnnotation.mappingVOClass();
if (!entityClass.isAnnotationPresent(Entity.class)) {
throw new CloudRuntimeException(String.format("class[%s] is not annotated by @Entity, but it's stated as entity class by @Inventory of %s",
代码示例来源:origin: zstackio/zstack
Inventory mappingInvAt = (Inventory) mappingInvClass.getAnnotation(Inventory.class);
DebugUtils.Assert(mappingInvAt != null, String.format("Mapping inventory class[%s] of inventory class[%s] is not annotated by @Inventory", mappingInvClass.getName(), inventoryClass.getName()));
Class foreignVOClass = mappingInvAt.mappingVOClass();
DebugUtils.Assert(FieldUtils.hasField(refName, foreignVOClass), String.format("referencedColumnName of JoinColumn of field[%s] on inventory class[%s] is invalid, class[%s] doesn't have field[%s]",
inventoryField.getName(), inventoryClass.getName(), foreignVOClass.getName(), refName));
代码示例来源:origin: zstackio/zstack
String primaryKey = EntityMetadata.getPrimaryKeyField(src.inventoryAnnotation.mappingVOClass()).getName();
String tableName = expr.getField().equals(USER_TAG_NAME) ? UserTagVO.class.getSimpleName() : SystemTagVO.class.getSimpleName();
代码示例来源:origin: zstackio/zstack
ExpandedSubQuery esub = (ExpandedSubQuery) subQueryInfo;
Inventory joinAt = (Inventory) esub.struct.getInventoryClass().getAnnotation(Inventory.class);
Class joinVO = joinAt.mappingVOClass();
Map<String, String> var = new HashMap<String, String>();
var.put("entity", parent.info.inventoryClass.getSimpleName().toLowerCase());
代码示例来源:origin: zstackio/zstack
if (!acntMgr.isResourceHavingAccountReference(src.inventoryAnnotation.mappingVOClass())) {
throw new SkipThisRestrictExprException();
String primaryKey = EntityMetadata.getPrimaryKeyField(src.inventoryAnnotation.mappingVOClass()).getName();
代码示例来源:origin: zstackio/zstack
emetadata.selfVOClass = inventory.mappingVOClass();
emetadata.targetVOClass = ((Inventory)targetInventoryClass.getAnnotation(Inventory.class)).mappingVOClass();
emetadata.targetInventoryClass = it.inventoryClass();
emetadata.selfKeyName = it.foreignKey();
emetadata.selfVOClass = inventory.mappingVOClass();
emetadata.targetVOClass = targetInventoryAnnotation.mappingVOClass();
emetadata.targetInventoryClass = gtype;
emetadata.selfKeyName = EntityMetadata.getPrimaryKeyField(emetadata.selfVOClass).getName();
代码示例来源:origin: zstackio/zstack
ZQLMetadata.InventoryMetadata dst = ZQLMetadata.findInventoryMetadata(node.getEntity());
DBGraph.EntityVertex vertex = DBGraph.findVerticesWithSmallestWeight(src.inventoryAnnotation.mappingVOClass(), dst.inventoryAnnotation.mappingVOClass());
if (vertex == null) {
if (ZQLGlobalProperty.ERROR_IF_NO_DB_GRAPH_RELATION) {
String primaryKey = EntityMetadata.getPrimaryKeyField(src.inventoryAnnotation.mappingVOClass()).getName();
template = String.format("(%s.%s IN %s)", src.simpleInventoryName(), primaryKey, template);
return String.format(template, node.getOperator(), ((ASTNode)node.getValue()).accept(new ValueVisitor()));
内容来源于网络,如有侵权,请联系作者删除!