コード例 #1
0
 public SEEntityStats entityStatsForEntityNamed(String entityName) {
   EOEntity entity = _modelGroup.entityNamed(entityName);
   EOModel model = entity.model();
   SEModelStats modelStats = modelStatsForModelNamed(model.name());
   SEEntityStats entityStats = modelStats.entityStatsForEntityNamed(entityName);
   return entityStats;
 }
コード例 #2
0
ファイル: DataCreator.java プロジェクト: hmng/wonder
  private void createTables(boolean dropTables) {
    for (Enumeration e = EOModelGroup.defaultGroup().models().objectEnumerator();
        e.hasMoreElements(); ) {
      final EOModel eomodel = (EOModel) e.nextElement();
      EODatabaseContext dbc = EOUtilities.databaseContextForModelNamed(ec, eomodel.name());
      dbc.lock();
      try {
        EOAdaptorChannel channel = dbc.availableChannel().adaptorChannel();
        if (eomodel.adaptorName().contains("JDBC")) {
          EOSynchronizationFactory syncFactory =
              (EOSynchronizationFactory)
                  channel.adaptorContext().adaptor().synchronizationFactory();
          ERXSQLHelper helper = ERXSQLHelper.newSQLHelper(channel);
          NSDictionary options = helper.defaultOptionDictionary(true, dropTables);

          // Primary key support creation throws an unwanted exception
          // if
          // EO_PK_TABLE already
          // exists (e.g. in case of MySQL), so we add pk support in a
          // stand-alone step
          options = optionsWithPrimaryKeySupportDisabled(options);
          createPrimaryKeySupportForModel(eomodel, channel, syncFactory);

          String sqlScript =
              syncFactory.schemaCreationScriptForEntities(eomodel.entities(), options);
          log.info("Creating tables: {}", eomodel.name());
          ERXJDBCUtilities.executeUpdateScript(channel, sqlScript, true);
        }
      } catch (SQLException ex) {
        log.error("Can't update", ex);
      } finally {
        dbc.unlock();
      }
    }
  }
コード例 #3
0
ファイル: Application.java プロジェクト: gavineadie/Pachyderm
    /*------------------------------------------------------------------------------------------------*
     *  A P P L I C A T I O N   W I L L   L A U N C H                     [ N O T I F I C A T I O N ]
     *------------------------------------------------------------------------------------------------*/
    public void appWillLaunch(NSNotification notification) {
      LOG.info("[-NOTIFY-] appWillLaunch");

      NSNotificationCenter.defaultCenter()
          .removeObserver(
              this,
              com.webobjects.appserver.WOApplication.ApplicationWillFinishLaunchingNotification,
              null);

      NSArray<EOModel> modelArray = ERXModelGroup.defaultGroup().models();
      for (EOModel model : modelArray) {
        LOG.info("[OBSERVER] modelName={} ({})", model.name(), model.adaptorName());
      }

      if (ERXProperties.booleanForKey("pachy.exitBeforeLaunching")) {
        LOG.info("[APPLICATION] EXIT BEFORE LAUNCHING [pachy.exitBeforeLaunching == true]");
        System.exit(0);
        /* ######################################### MIGHT STOP HERE (pachy.exitBeforeLaunching) #### */
      }

      if (ERXProperties.booleanForKeyWithDefault("pachy.optionEnableTimers", false)) {
        startTenMinuteTimerTask();
        startDayChangeTimerTask();
      }
    }
コード例 #4
0
 @SuppressWarnings({"unchecked"})
 protected void ensureModelsLoaded() {
   if (_modelStats == null) {
     _modelStats = new NSMutableDictionary<String, SEModelStats>();
     for (EOModel model : (NSArray<EOModel>) _modelGroup.models()) {
       SEModelStats modelStats = new SEModelStats(model);
       _modelStats.setObjectForKey(modelStats, model.name());
     }
   }
 }
コード例 #5
0
ファイル: _MySQLPlugIn.java プロジェクト: pgrbnsn/wonder
 private EOEntity entityForTableName(String tableName) {
   EOModelGroup modelGroup = EOModelGroup.globalModelGroup();
   for (EOModel model : modelGroup.models()) {
     for (EOEntity entity : model.entities()) {
       if (entity.externalName() != null && entity.externalName().equalsIgnoreCase(tableName)) {
         return entity;
       }
     }
   }
   return null;
 }
コード例 #6
0
ファイル: PluginTest.java プロジェクト: hypeastrum/wonder
  protected void resetData() {
    ERXEC ec = (ERXEC) ERXEC.newEditingContext();
    ERXEOAccessUtilities.ChannelAction action =
        new ERXEOAccessUtilities.ChannelAction() {
          @Override
          protected int doPerform(EOAdaptorChannel channel) {
            try {
              ERXJDBCUtilities.executeUpdateScript(
                  channel,
                  "update city set countryID = null;\n"
                      + "update country set capitalID = null;\n"
                      + "update countrylanguage set countryID = null;\n"
                      + "delete from city;\n "
                      + "delete from countrylanguage;\n"
                      + "delete from country;");

              final String sql =
                  ERXFileUtilities.stringFromInputStream(
                      ERXFileUtilities.inputStreamForResourceNamed("world.sql", null, null));
              ERXJDBCUtilities.executeUpdateScript(channel, sql);
            } catch (SQLException e) {
              log.error(org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(e), e);
              throw new NSForwardException(e);
            } catch (IOException e) {
              log.error(org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(e), e);
              throw new NSForwardException(e);
            }
            return 0;
          }
        };
    action.perform(ec, model.name());
  }
コード例 #7
0
ファイル: DataCreator.java プロジェクト: hmng/wonder
 private void createPrimaryKeySupportForModel(
     EOModel eomodel, EOAdaptorChannel channel, EOSynchronizationFactory syncFactory) {
   try {
     // AK: the (Object) cast is needed, because in 5.4 new NSArray(obj)
     // != new NSArray(array).
     NSArray pkSupportExpressions =
         syncFactory.primaryKeySupportStatementsForEntityGroups(
             new NSArray((Object) eomodel.entities()));
     Enumeration enumeration = pkSupportExpressions.objectEnumerator();
     while (enumeration.hasMoreElements()) {
       EOSQLExpression expression = (EOSQLExpression) enumeration.nextElement();
       channel.evaluateExpression(expression);
     }
   } catch (Exception e) {
   }
 }