本文整理了Java中org.zstack.zql.ast.ZQLMetadata.getInventoryMetadataByName()
方法的一些代码示例,展示了ZQLMetadata.getInventoryMetadataByName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZQLMetadata.getInventoryMetadataByName()
方法的具体详情如下:
包路径:org.zstack.zql.ast.ZQLMetadata
类名称:ZQLMetadata
方法名:getInventoryMetadataByName
暂无
代码示例来源:origin: zstackio/zstack
@Override
public void verify() {
if (right != null) {
InventoryMetadata him = getInventoryMetadataByName(right.targetInventoryClass.getName());
if (!him.hasInventoryField(fieldName)) {
throw new CloudRuntimeException(String.format("inventory class[%s] not having field[%s]", him.selfInventoryClass, fieldName));
}
} else {
if (!self.hasInventoryField(fieldName)) {
throw new CloudRuntimeException(String.format("inventory class[%s] not having field[%s]", self.selfInventoryClass, fieldName));
}
}
}
代码示例来源: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 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
em.self = self;
em.right = e;
self = getInventoryMetadataByName(em.right.targetInventoryClass.getName());
left = em.right;
ret.add(em);
代码示例来源:origin: zstackio/zstack
ZQLMetadata.InventoryMetadata src = ZQLMetadata.getInventoryMetadataByName(context.getQueryTargetInventoryName());
代码示例来源:origin: zstackio/zstack
@Override
public String visit(ASTNode.OrderBy node) {
if (!node.getDirection().equalsIgnoreCase("asc") && !node.getDirection().equalsIgnoreCase("desc")) {
throw new ZQLError(Platform.i18n("invalid order by clause, expect direction[asc,desc] but got %s", node.getDirection()));
}
String inventoryName = ZQLContext.peekQueryTargetInventoryName();
ZQLMetadata.InventoryMetadata m = ZQLMetadata.getInventoryMetadataByName(inventoryName);
if (!m.hasInventoryField(node.getField())) {
throw new ZQLError(Platform.i18n("invalid order by clause, inventory[%s] doesn't have field[%s]", m.simpleInventoryName(), node.getField()));
}
return String.format("ORDER BY %s %s", node.getField(), node.getDirection().toUpperCase());
}
}
代码示例来源:origin: zstackio/zstack
ZQLMetadata.InventoryMetadata src = ZQLMetadata.getInventoryMetadataByName(context.getQueryTargetInventoryName());
String accountUuid = context.getAPISession().getAccountUuid();
if (AccountConstant.INITIAL_SYSTEM_ADMIN_UUID.equals(accountUuid)) {
代码示例来源:origin: zstackio/zstack
ZQLMetadata.InventoryMetadata src = ZQLMetadata.getInventoryMetadataByName(srcTargetName);
ZQLMetadata.InventoryMetadata dst = ZQLMetadata.findInventoryMetadata(node.getEntity());
内容来源于网络,如有侵权,请联系作者删除!