Exemplo n.º 1
0
 public static EObject getSqlColumnDatatype(EObject eObject) {
   MetamodelAspect mmAspect = ModelObjectUtilities.getSqlAspect(eObject);
   if (mmAspect instanceof SqlColumnAspect) {
     SqlColumnAspect sqAspect = (SqlColumnAspect) mmAspect;
     return sqAspect.getDatatype(eObject);
   }
   return null;
 }
Exemplo n.º 2
0
  public static boolean setParameterSignature(EObject eObject, String newSignature)
      throws ModelerCoreException {
    MetamodelAspect mmAspect = ModelObjectUtilities.getSqlAspect(eObject);
    if (mmAspect instanceof SqlProcedureParameterAspect) {
      // Now we parse the name
      int index = newSignature.indexOf(COLON);
      boolean canSetLength = ((SqlProcedureParameterAspect) mmAspect).canSetLength();
      if (index > 0) {
        SqlProcedureParameterAspect sppAspect = (SqlProcedureParameterAspect) mmAspect;
        String newName = newSignature.substring(0, index).trim();
        index++;
        String fullDatatype = newSignature.substring(index);
        if (fullDatatype.length() > 0) {

          String dTypeString = null;

          // Check to see if length is included
          int indexLeft = fullDatatype.indexOf(LEFT_PARENTH);
          int indexRight = fullDatatype.indexOf(RIGHT_PARENTH);
          if (indexLeft > 0) dTypeString = fullDatatype.substring(0, indexLeft).trim();
          else dTypeString = fullDatatype.trim();

          if (indexRight > 0 && canSetLength) {
            String lengthString = fullDatatype.substring(indexLeft + 1, indexRight).trim();
            int length = -1;
            try {
              length = Integer.parseInt(lengthString);
            } catch (NumberFormatException nfe) {

            }
            if (length >= 0) sppAspect.setLength(eObject, length);
          }
          // --------------------
          // Defect 22275 - Needed to do one more check to see if the aspect supports setting
          // datatype.
          // XML Document attributes do have a sqlColumnAspect but don't support datatypes
          // --------------------
          if (sppAspect.canSetDatatype() && dTypeString != null && dTypeString.length() > 0) {
            EObject dType = getDatatype(dTypeString);
            if (dType != null) {
              sppAspect.setDatatype(eObject, dType);
            }
          }
        }

        ModelerCore.getModelEditor().rename(eObject, newName);
        return true;
      }

      String newName = newSignature.trim();
      ModelerCore.getModelEditor().rename(eObject, newName);
      return true;
    }
    return false;
  }
Exemplo n.º 3
0
 public static boolean renameSqlColumn(EObject newEObject, String newName)
     throws ModelerCoreException {
   MetamodelAspect mmAspect = ModelObjectUtilities.getSqlAspect(newEObject);
   if (mmAspect instanceof SqlColumnAspect) {
     if (newName != null && newName.length() > 0) {
       DatatypeUtilities.setColumnSignature(newEObject, newName);
     }
     return true;
   }
   if (mmAspect instanceof SqlProcedureParameterAspect) {
     if (newName != null && newName.length() > 0) {
       DatatypeUtilities.setParameterSignature(newEObject, newName);
     }
     return true;
   }
   return false;
 }