Пример #1
0
  public void addAttribute(Attribute attribute) {
    attribute.setSchema(this);
    // comprobación de clones de tablas
    GeopistaSchema schema = this;

    // busca si existe otra tabla con este nombre
    // java2xml desvincula las tablas y crea múltiples instancias

    for (int i = 0; i < schema.getAttributeCount(); i++) {
      if (schema
          .getColumnByAttribute(i)
          .getTable()
          .getName()
          .equals(attribute.getColumn().getTable().getName())) {
        // Es un clon de la ya existente -> uso la existente en lugar del parámetro.
        attribute.getColumn().setTable(schema.getColumnByAttribute(i).getTable());
      }
    }
    /**
     * Busca si existe un dominio con el mismo nombre de tipo TreeDomain java2xml desvincula los
     * dominios y crea instancias separadas
     */
    Domain newdomain = attribute.getColumn().getDomain();
    if (newdomain instanceof TreeDomain) {
      TreeDomain newTreeDomain = (TreeDomain) newdomain;
      // busca por nombre de dominio
      for (int i = 0; i < schema.getAttributeCount(); i++) {
        if (schema.getAttributeDomain(i) != null
            && schema.getAttributeDomain(i).getName().equals(newTreeDomain.getName())) {
          // se ha encontrado el dominio ya definido: Usamos el actual
          Domain dom = schema.getAttributeDomain(i);
          newTreeDomain = (TreeDomain) dom; // overrides suplied domain
        }
      }
      attribute.getColumn().setDomain(newTreeDomain);
      //		 enlaza la columna actual al dominio existente
      int level = newTreeDomain.getLevelNames().indexOf(attribute.getColumn().getName());
      if (level > -1) newTreeDomain.attachColumnToLevel(attribute.getColumn(), level);
    }

    addAttribute(
        attribute.getName(),
        AttributeType.toAttributeType(attribute.getType()),
        attribute.getColumn(),
        attribute.getAccessType());
  }
Пример #2
0
  /**
   * Añade todos los atributos de las capas seleccionadas
   *
   * @param extractLayers
   * @return
   */
  private NamedVector[] getRootLayerNodes(ArrayList<GeopistaLayer> extractLayers) {
    NamedVector[] returnVector = null;
    if (extractLayers != null) {
      GeopistaLayer geopistaLayer = null;
      String layerSystemId;
      EIELFilesUtils eielFilesUtils;
      String layerName;
      returnVector = new NamedVector[extractLayers.size()];
      // capas
      for (int i = 0; i < extractLayers.size(); i++) {
        geopistaLayer = extractLayers.get(i);
        layerSystemId = geopistaLayer.getSystemId();
        eielFilesUtils = new EIELFilesUtils(layerSystemId);
        layerName = geopistaLayer.getName();

        // buscamos el identificador de cada capa
        GeopistaSchema featureGeoSchema =
            (GeopistaSchema) geopistaLayer.getFeatureCollectionWrapper().getFeatureSchema();
        // atributos
        NamedVector namedVector = new NamedVector(layerName);
        Column columnByAttribute = null;
        String colName = null;
        for (int j = 0; j < featureGeoSchema.getAttributeCount(); j++) {
          columnByAttribute = featureGeoSchema.getColumnByAttribute(j);
          colName = columnByAttribute.getName();
          if (colName.toLowerCase().equals(GEOMETRY_ATR)) { // no lo mostramos
            continue;
          }
          // CAMBIAR: COMPROBAR SI SE DEBE SELECCIONAR id SI ES TIPO EIEL
          else if (colName.toLowerCase().equals(Constants.FIELD_ID)) { // lo ponemos al principio
            namedVector.add(0, new CheckBoxNode(featureGeoSchema.getAttributeName(j), true, false));
          } else if (colName.toLowerCase().equals(Constants.FIELD_ID_MUNICIPIO)) {
            namedVector.add(1, new CheckBoxNode(featureGeoSchema.getAttributeName(j), true, false));
          }
          // caso especial para licencias
          // la referencia castastral será el atributo clave para localizar la licencia
          else if (colName.toLowerCase().contains(Constants.CLAVE_METAINFO)
              && Utils.isInArray(Constants.TIPOS_LICENCIAS, layerSystemId)) {
            namedVector.add(new CheckBoxNode(featureGeoSchema.getAttributeName(j), true, false));
          }
          // caso especial para inventario de patrimonio
          else if (colName.toLowerCase().equals(Constants.NUM_BIENES_ID)
              && Utils.isInArray(Constants.TIPOS_INVENTARIO, layerSystemId)) {
            namedVector.add(new CheckBoxNode(featureGeoSchema.getAttributeName(j), true, false));
          }
          // caso especial para EIEL
          else if (Utils.isInArray(Constants.TIPOS_EIEL, layerSystemId)) {
            if (isPkFieldEIEL(eielFilesUtils, layerSystemId, colName))
              namedVector.add(new CheckBoxNode(featureGeoSchema.getAttributeName(j), true, false));
            else
              namedVector.add(new CheckBoxNode(featureGeoSchema.getAttributeName(j), false, true));
          } else { // simplemente lo añadimos
            // if(!(licUtils.isInArray(Constants.TIPOS_LICENCIAS, layerSystemId) ||
            // licUtils.isInArray(Constants.TIPOS_INVENTARIO, layerSystemId))){
            if (!Utils.isInArray(Constants.TIPOS_LICENCIAS, layerSystemId)) {
              namedVector.add(new CheckBoxNode(featureGeoSchema.getAttributeName(j), false, true));
            }
          }
        }
        returnVector[i] = namedVector;
      }
    }

    return returnVector;
  }