Package org.objectweb.speedo.metadata

Examples of org.objectweb.speedo.metadata.SpeedoColumn


            continue;
          }
                    SpeedoInheritedField sif =
                        sc.inheritance.newSpeedoInheritedField((SpeedoField)inhsf);
                    for (SpeedoColumn scol : sif.inheritedField.columns) {
            SpeedoColumn nscol = (SpeedoColumn) scol.clone();
            nscol.table = sc.mainTable;
            sif.addColumn(nscol);
          }
        }
        inhsc = inhsc.getSuper();
View Full Code Here


   * @param col  The annotation to extract information from.
   * @param sc  The SpeedoClass under construction.
   * @param sf  The SpeedoField under construction.
   */
  private void parseColumn(Column col, SpeedoClass sc, SpeedoField sf) {
    SpeedoColumn scol = new SpeedoColumn();
    if (col == null) {
      if (sf.relationType != SpeedoField.NO_BI_RELATION) {
        return;
      }
      scol.name = sf.name;
View Full Code Here

  private void parseOverrideColumn(Column col, SpeedoClass sc, SpeedoInheritedField sf) {
    // TODO: code copy from parseColumn->implement!!
    if (col == null) {
      return;
    }
    SpeedoColumn scol = new SpeedoColumn();
    if (!col.table().equals("")) {
      scol.table = sc.getExtTable(col.table(), true);
    } else {
      scol.table = sc.mainTable;
    }
View Full Code Here

    /*TODO sf.join.extTable = parseTable(jt.table(), sc, null);*/
    sf.join.mainTable = sc.mainTable;
    // Parse joinColumns from JoinTable (may be empty)
    for (JoinColumn jc : jt.joinColumns()) {
      SpeedoJoinColumn sjcol = new SpeedoJoinColumn();
      sjcol.column = new SpeedoColumn();
      if (jc.referencedColumnName().equals("")) {
        if (jc.name().equals("")) {
          nbErrors++;
          logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
              + ": must define at least columnName or referencedColumnName for m-n relationship field ("
              + sf.name + ") - mapping information ignored.");
          continue;
        }
        sjcol.column.name = jc.name();
        sjcol.column.targetColumn = sjcol.column.name;
      } else {
        sjcol.column.targetColumn = jc.referencedColumnName();
        if (jc.name().equals("")) {
          sjcol.column.name = sjcol.column.targetColumn;
        } else {
          sjcol.column.name = jc.name();
        }
      }
      sjcol.targetColumn = sjcol.column.targetColumn;
      sjcol.column.table = sf.join.mainTable;
      sf.join.columns.add(sjcol);
    }
    // parse inverseJoinColumns from JoinTable
    for (JoinColumn jc : jt.inverseJoinColumns()) {
      SpeedoColumn scol = new SpeedoColumn();
      if (jc.referencedColumnName().equals("")) {
        if (jc.name().equals("")) {
          nbErrors++;
          logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
              + ": must define at least columnName or referencedColumnName for m-n relationship field ("
View Full Code Here

    }
    if (sf.relationType == SpeedoField.MANY_REFERENCE) {
      sf.join = new SpeedoJoin();
    }
    for (JoinColumn jc : jcs) {
      SpeedoColumn scol = new SpeedoColumn();
      scol.targetColumn = jc.referencedColumnName();
      if (scol.targetColumn.equals("")) {
        if (jcs.length > 1) {
          nbErrors++;
          logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
              + ": try to define the join of a reference or association field ("
              + sf.name + ") without defining names of referenced columns.");
          continue;
        }
      }
      if (jc.name().equals("")) {
        if (jcs.length > 1) {
          nbErrors++;
          logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
              + ": try to define the join of a reference or association field ("
              + sf.name + ") without defining names of join columns.");
          continue;
        }
        scol.name = sf.name + "_" + scol.targetColumn;
      } else {
        scol.name = jc.name();
      }
      if (! jc.table().equals("")) {
        scol.table = sc.getExtTable(jc.table(), true);
      } else {
        scol.table = sc.mainTable;
      }
      if (sf.relationType == SpeedoField.MANY_REFERENCE) {
        if (sf.join.mainTable == null) {
          sf.join.mainTable = scol.table;
        } else if (sf.join.mainTable != scol.table) {
          nbErrors++;
          logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
              + ": cannot map the reference field ("
              + sf.name + ") to columns belonging to several tables.");
          continue;
        }
      }
      SpeedoColumn fscol = sc.getColumn(scol.name, false);
      if ((fscol != null) && (fscol.table == scol.table)) {
        nbErrors++;
        logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
            + ": cannot define a column twice for column named ("
            + scol.name + ").");
View Full Code Here

    for (int i = 0; i < ucs.length; i++) { // iterate over constraints
      ArrayList cols = new ArrayList();
      int j;
      for (j = 0; j < ucs[i].columnNames().length; j++) {
        // Look for the column in those defined within the SpeedoClass
        SpeedoColumn c = searchColumn(sc, ucs[i].columnNames()[j], t);
        // Did not find the column
        if (c == null) {
          nbErrors++;
          logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
              + ": try to associate a unique constraint with a column ("
              + ucs[i].columnNames()[j]
              + ") that does not exist (ignored).");
          break;
        }
        // Insert (sorted) the column into the list specifying the constraint
        Iterator itc = cols.iterator();
        int pos = 0;
        while (itc.hasNext()) {
          SpeedoColumn ct = (SpeedoColumn) itc.next();
          if (c == ct) { // already present: ignored
            pos = -1;
            break;
          }
          if (c.name.compareTo(ct.name) > 0) {
View Full Code Here

          continue;
        } else {
          sjc.column = searchColumn(sc, jc.name(), sj.extTable);
          if (sjc.column == null) {
            // Unknown column: define a new one
            sjc.column = new SpeedoColumn();
            sjc.column.name = jc.name();
            sjc.column.sqlType = jc.columnDefinition();
            sjc.column.table = sj.extTable;
          }
        }
View Full Code Here

   * @param cname  The name of the column to be searched.
   * @param t    The SpeedoTable to which it should belong.
   * @return  The column found or null if none.
   */
  private SpeedoColumn searchColumn(SpeedoClass sc, String cn, SpeedoTable t) {
    SpeedoColumn c = null;
    Iterator itf = sc.fields.values().iterator();
    while (itf.hasNext()) {
      SpeedoField ft = (SpeedoField) itf.next();
      for (int k = 0; k < ft.columns.length; k++) {
        if (ft.columns[k].table != t) {
View Full Code Here

     */
    private void visitPrimitiveField(SpeedoField sf) throws SpeedoException {
        logger.log(BasicLevel.DEBUG, "\t\tvisit field primitive '" + sf.name + "'.");
        if (sf.columns == null) {
            logger.log(BasicLevel.DEBUG, "\t\tcreate new Column.");
            sf.addColumn(new SpeedoColumn());
        }
        SpeedoColumn col = sf.columns[0];
        if (col.table == null) {
          if (sf.join == null) {
              col.table = sf.moClass.mainTable;
          } else {
              col.table = sf.join.extTable;
View Full Code Here

        SpeedoColumn[] pkColumns = getIdColumns(rclass);
        SpeedoColumn[] columns = new SpeedoColumn[pkColumns.length];
        for(int i=0; i<pkColumns.length; i++) {
            //create new SpeedoColumn instance targeting pk column
            // with the same description (sql type, length, scale, ...)
            columns[i] = new SpeedoColumn();
            columns[i].targetColumn = pkColumns[i].name;
            columns[i].name = colPrefix + columns[i].targetColumn;
            columns[i].table = table;
            columns[i].sqlType = pkColumns[i].sqlType;
            columns[i].scale = pkColumns[i].scale;
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.metadata.SpeedoColumn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.