org.zstack.header.search.Inventory类的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中org.zstack.header.search.Inventory类的一些代码示例,展示了Inventory类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Inventory类的具体详情如下:
包路径:org.zstack.header.search.Inventory
类名称:Inventory

Inventory介绍

暂无

代码示例

代码示例来源:origin: zstackio/zstack

@Inventory(mappingVOClass = SimulatorHostVO.class)
public class SimulatorHostInventory extends HostInventory {
  private Long memoryCapacity;

代码示例来源:origin: zstackio/zstack

public static Class getEntityClassFromInventoryClass(Class invClz) {
  Inventory at = (Inventory) invClz.getAnnotation(Inventory.class);
  return at.mappingVOClass();
}

代码示例来源:origin: zstackio/zstack

String collectionMethodName = "valueOf";
  Inventory at = clz.getAnnotation(Inventory.class);
  if (!at.collectionValueOfMethod().equals("")) {
    collectionMethodName = at.collectionValueOfMethod();
          && 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

for (Parent parent : inventory.parent()) {
  Class parentInventory = parent.inventoryClass();
  Map<String, Class> children = typeFieldToParentInventory.computeIfAbsent(parentInventory, x->new HashMap<>());
    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

void buildFlatTypeEntityMap() {
  for (EntityInfo e : children) {
    Parent pat = e.inventoryAnnotation.parent()[0];
    flatTypeEntityMap.put(pat.type(), e);
  }
}

代码示例来源:origin: zstackio/zstack

private void populateEntityInfo() throws NoSuchMethodException {
  Set<Class<?>> metaClasses = BeanUtils.reflections.getTypesAnnotatedWith(StaticMetamodel.class);
  for (Class it : metaClasses) {
    StaticMetamodel at = (StaticMetamodel) it.getAnnotation(StaticMetamodel.class);
    metaModelClasses.put(at.value(), it);
  }
  Set<Class<?>> invClasses = BeanUtils.reflections.getTypesAnnotatedWith(Inventory.class);
  for (Class invClass : invClasses) {
    EntityInfo info = buildEntityInfo(invClass);
    if (info.inventoryAnnotation.parent().length > 0) {
      Parent pat = info.inventoryAnnotation.parent()[0];
      Class pinvClass = pat.inventoryClass();
      DebugUtils.Assert(pinvClass.isAnnotationPresent(Inventory.class), String.format("inventory[%s]'s parent inventory class[%s] is not annotated by @Inventory", info.inventoryClass.getName(), pinvClass.getName()));
      EntityInfo pinfo = buildEntityInfo(pinvClass);
      info.parent = pinfo;
      pinfo.children.add(info);
    }
  }
  for (EntityInfo e : entityInfos.values()) {
    e.buildFlatTypeEntityMap();
  }
}

代码示例来源:origin: zstackio/zstack

@Inventory(mappingVOClass = NetworkServiceTypeVO.class)
public class NetworkServiceTypeInventory {
  private String networkServiceProviderUuid;

代码示例来源: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

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",
  String methodName = inventoryAnnotation.collectionValueOfMethod();
  if (methodName.equals("")) {
    methodName = "valueOf";

代码示例来源:origin: zstackio/zstack

@Inventory(mappingVOClass = NetworkServiceProviderL2NetworkRefVO.class)
public class NetworkServiceProviderL2NetworkRefInventory {
  private String networkServiceProviderUuid;

代码示例来源: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

@Inventory(mappingVOClass = SystemTagVO.class)
public class SystemTagInventory extends TagInventory {
  private Boolean inherent;

代码示例来源: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

@Inventory(mappingVOClass = ResourceVO.class)
public class ResourceInventory {
  protected String uuid;

代码示例来源: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

@Inventory(mappingVOClass = L3NetworkDnsVO.class)
public class L3NetworkDnsInventory {
  private String l3NetworkUuid;

代码示例来源: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

@Inventory(mappingVOClass = L3NetworkHostRouteVO.class)
public class L3NetworkHostRouteInventory {
  private Long   id;

代码示例来源: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

@Inventory(mappingVOClass = IpUseVO.class)
public class IpUseInventory {
  private String uuid;

相关文章