示例#1
0
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  public void createControl(Composite parent) {
    // TODO Auto-generated method stub
    currentComposite = null;
    WSDLSchemaConnection connection = ((WSDLSchemaConnection) connectionItem.getConnection());
    if (ConnectionHelper.getTables(connection).size() < 2) {
      MetadataTable metadataTable =
          ConnectionHelper.getTables(connection).toArray(new MetadataTable[0])[0];
      metadataTable.setLabel("Output");
      MetadataTable inPutMetadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
      IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
      inPutMetadataTable.setLabel("Input");
      inPutMetadataTable.setId(factory.getNextId());
      GenericPackage g =
          (GenericPackage)
              ConnectionHelper.getPackage(
                  connection.getName(), (Connection) connection, GenericPackage.class);
      if (g != null) { // hywang
        g.getOwnedElement().add(inPutMetadataTable);
        ConnectionHelper.getTables(connection).add(inPutMetadataTable);
      } else {
        GenericPackage gpkg = ConnectionFactory.eINSTANCE.createGenericPackage();
        PackageHelper.addMetadataTable(inPutMetadataTable, gpkg);
        ConnectionHelper.addPackage(gpkg, connection);
      }
      // connection.getTables().add(inPutMetadataTable);
    }

    switch (step) {
      case 2:
        currentComposite =
            new WebServiceStep1Form(
                parent, connectionItem, null, new String[] {}, contextModeManager);
        break;
      case 3:
        MetadataTable metadataTable2 = null;
        Set<MetadataTable> tables = ConnectionHelper.getTables(connection);
        Iterator<MetadataTable> it = tables.iterator();
        while (it.hasNext()) {
          MetadataTable table = (MetadataTable) it.next();
          if (table.getLabel().equals("Output")) {
            metadataTable2 = table;
          }
        }
        currentComposite =
            new WebServiceStep2Form(parent, connectionItem, contextModeManager, metadataTable2);
        break;
      default:
        System.out.println("error...");
    }
    currentComposite.setReadOnly(!isRepositoryObjectEditable);
    AbstractForm.ICheckListener listener =
        new AbstractForm.ICheckListener() {

          public void checkPerformed(final AbstractForm source) {

            if (source.isStatusOnError()) {
              WebServiceSchemaWizardPage.this.setPageComplete(false);
              setErrorMessage(source.getStatus());
            } else {
              WebServiceSchemaWizardPage.this.setPageComplete(isRepositoryObjectEditable);
              setErrorMessage(null);
              setMessage(source.getStatus());
            }
          }
        };
    currentComposite.setListener(listener);
    setControl((Composite) currentComposite);
  }
示例#2
0
  public SalesforceSchemaWizard(
      IWorkbench workbench,
      boolean creation,
      RepositoryNode node,
      String[] existingNames,
      boolean isSinglePageOnly) {
    super(workbench, creation);
    this.existingNames = existingNames;
    this.isSinglePageOnly = isSinglePageOnly;
    setNeedsProgressMonitor(true);

    // TODO: should to changed icon.
    setDefaultPageImageDescriptor(ImageProvider.getImageDesc(ECoreImage.DEFAULT_WIZ));
    switch (node.getType()) {
      case SIMPLE_FOLDER:
      case REPOSITORY_ELEMENT:
        pathToSave = RepositoryNodeUtilities.getPath(node);
        break;
      case SYSTEM_FOLDER:
        pathToSave = new Path(""); // $NON-NLS-1$
        break;
    }

    switch (node.getType()) {
      case SIMPLE_FOLDER:
      case SYSTEM_FOLDER:
        connection = ConnectionFactory.eINSTANCE.createSalesforceSchemaConnection();
        connection.setName(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA.getKey());
        MetadataTable metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        metadataTable.setId(factory.getNextId());
        RecordFile record =
            (RecordFile)
                ConnectionHelper.getPackage(connection.getName(), connection, RecordFile.class);
        if (record != null) { // hywang
          PackageHelper.addMetadataTable(metadataTable, record);
        } else {
          RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
          newrecord.setName(connection.getName());
          ConnectionHelper.addPackage(newrecord, connection);
          PackageHelper.addMetadataTable(metadataTable, newrecord);
        }
        connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
        connectionProperty.setAuthor(
            ((RepositoryContext)
                    CoreRuntimePlugin.getInstance()
                        .getContext()
                        .getProperty(Context.REPOSITORY_CONTEXT_KEY))
                .getUser());
        connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
        connectionProperty.setStatusCode(""); // $NON-NLS-1$

        connectionItem = PropertiesFactory.eINSTANCE.createSalesforceSchemaConnectionItem();
        connectionItem.setProperty(connectionProperty);
        connectionItem.setConnection(connection);
        initProxySettings(connection);
        break;

      case REPOSITORY_ELEMENT:
        connection =
            (SalesforceSchemaConnection)
                ((ConnectionItem) node.getObject().getProperty().getItem()).getConnection();
        connectionProperty = node.getObject().getProperty();
        connectionItem = (ConnectionItem) node.getObject().getProperty().getItem();
        // set the repositoryObject, lock and set isRepositoryObjectEditable
        setRepositoryObject(node.getObject());
        isRepositoryObjectEditable();
        initLockStrategy();
        break;
    }
    if (!creation) {
      this.originaleObjectLabel = this.connectionItem.getProperty().getLabel();
      this.originalVersion = this.connectionItem.getProperty().getVersion();
      this.originalDescription = this.connectionItem.getProperty().getDescription();
      this.originalPurpose = this.connectionItem.getProperty().getPurpose();
      this.originalStatus = this.connectionItem.getProperty().getStatusCode();
    }
    initConnection();
  }
  private static void addTableForTemCatalogOrSchema(
      String dbsid,
      String schema,
      DatabaseConnection connection,
      MetadataTable dbtable,
      IMetadataConnection iMetadataConnection,
      int stackCount)
      throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
    if (3 < stackCount) {
      // if loop count is more than 3 times, seems it will never end this loop, and will never get
      // the dbsid and
      // schema
      return;
    }
    boolean hasSchemaInCatalog = false;
    boolean isAccess =
        EDatabaseTypeName.ACCESS.getDisplayName().equals(iMetadataConnection.getDbType());
    Catalog c = (Catalog) ConnectionHelper.getPackage(dbsid, connection, Catalog.class);
    Schema s = (Schema) ConnectionHelper.getPackage(schema, connection, Schema.class);
    List<Schema> subschemas = new ArrayList<Schema>();
    if (c != null) {
      subschemas = CatalogHelper.getSchemas(c);
      hasSchemaInCatalog = subschemas.size() > 0;
    }
    if (c != null && s == null && !hasSchemaInCatalog) { // only catalog
      PackageHelper.addMetadataTable(dbtable, c);

    } else if (s != null && !hasSchemaInCatalog && c == null) { // only schema
      PackageHelper.addMetadataTable(dbtable, s);
    } else if (c != null && hasSchemaInCatalog) { // both schema and catalog
      subschemas = CatalogHelper.getSchemas(c);
      hasSchemaInCatalog = subschemas.size() > 0;
      if (subschemas.size() > 0) {
        for (Schema current : subschemas) {
          if (current.getName().equals(schema)) {
            s = current;
            break;
          }
        }

        if (s != null) {
          // for bug 16794
          if (s instanceof SchemaImpl) {
            SchemaImpl schemaElement = (SchemaImpl) s;
            EList<ModelElement> ownedElement = schemaElement.getOwnedElement();
            ownedElement.add(dbtable);
          }
        } else if (subschemas.size() > 0) {
          // added for bug 17467
          // set db connection's schema as null, and retrieve schema again, to add some tables
          for (int i = 0; i < subschemas.size(); i++) {
            SchemaImpl schemaElement = (SchemaImpl) subschemas.get(i);
            EList<ModelElement> ownedElement = schemaElement.getOwnedElement();
            ownedElement.add(dbtable);
          }
        }
        // PackageHelper.addMetadataTable(dbtable, s);
      }
    } else if (s == null
        && c == null
        && !isAccess
        && stackCount == 1) { // TDI-20584:after migration from 4.0 to
      // 4.2,lost all catalogs
      // and schemas for database
      // in case after migration connetion from the version before 4.0,there is no any db structure
      // on
      // temConnection,it will casue pbs,so sychronize with imetadataConnection
      fillCatalogAndSchemas(iMetadataConnection, connection);
      addTableForTemCatalogOrSchema(
          dbsid, schema, connection, dbtable, iMetadataConnection, stackCount + 1);
    } else {
      /*
       * if there is no catalog or schema,create the structure correctly rather than always create a catalog,found
       * this issue when fixing bug 16636
       */
      ProjectNodeHelper.addCatalogOrSchema(iMetadataConnection, connection);
      if (isAccess) {
        addTableForTemCatalogOrSchema(
            dbsid, connection.getName(), connection, dbtable, iMetadataConnection, stackCount + 1);
      } else {
        addTableForTemCatalogOrSchema(
            dbsid, schema, connection, dbtable, iMetadataConnection, stackCount + 1);
      }
    }
  }