示例#1
0
 protected static String resolveEntity(String entityName, EOEditingContext ec) {
   if (entityName == null) return null;
   try {
     EOEntity entity = EOUtilities.entityNamed(ec, entityName);
     if (entity != null) {
       return entityName;
     }
   } catch (EOObjectNotAvailableException naex) {
   }
   entityName = SettingsReader.stringForKeyPath("interfaces." + entityName, null);
   int dot = entityName.lastIndexOf('.');
   if (dot > 0) {
     entityName = entityName.substring(dot + 1);
   }
   //		return resolveEntity(entityName);
   if (entityName == null) return null;
   try {
     EOEntity entity = EOUtilities.entityNamed(ec, entityName);
     if (entity != null) {
       return entityName;
     }
   } catch (EOObjectNotAvailableException naex2) {
   }
   return null;
 }
示例#2
0
  public WOActionResults createDataStore() throws IOException, MessagingException {
    File emailFile = new File("Resources/largeEmail.eml");
    javax.mail.Message message = convertEmlToMessage(emailFile);

    EOObjectStore osc = new ERXObjectStoreCoordinator(true);
    EOEditingContext ec = ERXEC.newEditingContext(osc);
    ec.lock();
    try {
      DataContainer container =
          (DataContainer)
              EOUtilities.createAndInsertInstance(ec, DataContainer.class.getSimpleName());

      DataStore dataStore =
          (DataStore) EOUtilities.createAndInsertInstance(ec, DataStore.class.getSimpleName());
      dataStore.setDataContainer(container);

      ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
      message.writeTo(byteStream);
      NSData rawEmail = new NSData(byteStream.toByteArray());
      dataStore.setData(rawEmail);

      ec.saveChanges();
    } finally {
      ec.unlock();
      ec.dispose();
      osc.dispose();
      ec = null;
      osc = null;
    }
    return null;
  }
示例#3
0
 public WOActionResults saveType() {
   EOEditingContext ec = (EOEditingContext) valueForBinding("ec");
   ec.lock();
   try {
     boolean newType = (currType == null);
     if (newType) {
       currType = (ItogType) EOUtilities.createAndInsertInstance(ec, ItogType.ENTITY_NAME);
       Number maxSort = (Number) valueForBinding("maxSort");
       if (maxSort != null) {
         currType.setSort(new Integer(maxSort.intValue() + 1));
       } else {
         currType.setSort(new Integer(1));
       }
     }
     currType.setName(itogName);
     currType.setTitle(itogTitle);
     currType.setInYearCount((itogCount == null) ? new Integer(0) : itogCount);
     ec.saveChanges();
     //			if(newType) {
     //				allTypes = allTypes.arrayByAddingObject(currType);
     //				itogsList = NSArray.EmptyArray;
     //			}
     setValueForBinding(currType, "currType");
   } catch (Exception e) {
     SetupItogs.logger.log(WOLogLevel.WARNING, "Error saving changes in list ", e);
     session().takeValueForKey(e.getMessage(), "message");
     ec.revert();
   } finally {
     ec.unlock();
   }
   return (WOActionResults) valueForBinding("actionResult");
 }
示例#4
0
  public void appendToResponse(WOResponse aResponse, WOContext aContext) {
    try {
      Number b = (Number) valueForBinding("firstNameDisplay");
      if (b != null) firstNameDisplay = b.intValue();
      else firstNameDisplay = 2;

      b = (Number) valueForBinding("secondNameDisplay");
      if (b != null) secondNameDisplay = b.intValue();
      else secondNameDisplay = 2;

    } catch (ClassCastException cex) {
      throw new IllegalArgumentException("NameDisplay bindings should be integer");
    }
    String request = (String) valueForBinding("searchRequest");
    if (request != null) {
      performSearchRequest(request);
    } else {
      selection =
          (PersonLink)
              EOUtilities.localInstanceOfObject(
                  ec, (EOEnterpriseObject) valueForBinding("selection"));
      //			syncSelection();
    }
    if (selection == null && Various.boolForObject(valueForBinding("showPopup"))) {
      selection = defaultSelectionValue();
      setValueForBinding(selection, "selection");
    }
    super.appendToResponse(aResponse, aContext);
    found = null;
    //		searchMessage = null;
  }
示例#5
0
 public WOActionResults delete() {
   EOEditingContext ec = (EOEditingContext) valueForBinding("ec");
   ec.lock();
   try {
     NSArray usage =
         EOUtilities.objectsMatchingKeyAndValue(ec, "ItogTypeList", "itogType", currType);
     if (usage != null && usage.count() > 0) {
       Enumeration enu = usage.objectEnumerator();
       while (enu.hasMoreElements()) {
         EOEnterpriseObject itl = (EOEnterpriseObject) enu.nextElement();
         ec.deleteObject(itl);
       }
     }
     ec.deleteObject(currType);
     ec.saveChanges();
     currType = null;
     setValueForBinding(currType, "currType");
   } catch (Exception e) {
     SetupItogs.logger.log(WOLogLevel.WARNING, "Error saving changes in list ", e);
     session().takeValueForKey(e.getMessage(), "message");
     ec.revert();
   } finally {
     ec.unlock();
   }
   return (WOActionResults) valueForBinding("actionResult");
 }
示例#6
0
  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();
      }
    }
  }
示例#7
0
 public static Category createCategory(EOEditingContext editingContext, Integer id, String name) {
   Category eo =
       (Category) EOUtilities.createAndInsertInstance(editingContext, _Category.ENTITY_NAME);
   eo.setId(id);
   eo.setName(name);
   return eo;
 }
示例#8
0
 public static EOBap createBap(
     EOEditingContext editingContext, NSTimestamp dCreation, NSTimestamp dModification) {
   EOBap eo = (EOBap) EOUtilities.createAndInsertInstance(editingContext, _EOBap.ENTITY_NAME);
   eo.setDCreation(dCreation);
   eo.setDModification(dModification);
   return eo;
 }
 /**
  * Retrieve this object's <code>id</code> value.
  *
  * @return the value of the attribute
  */
 public Number id() {
   try {
     return (Number) EOUtilities.primaryKeyForObject(editingContext(), this).objectForKey("id");
   } catch (Exception e) {
     return er.extensions.eof.ERXConstant.ZeroInteger;
   }
 }
 public NSArray faxFournis() {
   NSDictionary args = new NSDictionary(persId(), "persId");
   NSArray results =
       EOUtilities.objectsWithFetchSpecificationAndBindings(
           editingContext(), "PersonneTelephone", "faxForPersId", args);
   return EOPersonneTelephone.prepareFetchResultForDisplay(results, false);
 }
示例#11
0
  public EOQualifier qualifierForRelationshipWithKey(String aKey) {
    willRead();

    if (aKey != null) {
      String anEntityName = entityName();
      EOEntity anEntity = EOModelGroup.defaultGroup().entityNamed(anEntityName);
      EORelationship aRelationship = anEntity.relationshipNamed(aKey);

      if (aRelationship != null) {
        EOEditingContext anEditingContext = editingContext();
        EOGlobalID aGlobalID = anEditingContext.globalIDForObject(this);
        String aModelName = anEntity.model().name();
        EODatabaseContext aDatabaseContext =
            EOUtilities.databaseContextForModelNamed(anEditingContext, aModelName);
        aDatabaseContext.lock();
        NSDictionary aRow = aDatabaseContext.snapshotForGlobalID(aGlobalID);
        aDatabaseContext.unlock();
        EOQualifier aQualifier = aRelationship.qualifierWithSourceRow(aRow);

        return aQualifier;
      }
    }

    return null;
  }
示例#12
0
 public void appendToResponse(WOResponse aResponse, WOContext aContext) {
   ItogType type = (ItogType) valueForBinding("currType");
   currType = type;
   NamedFlags access = (NamedFlags) valueForBinding("access");
   if (access == null)
     access = (NamedFlags) session().valueForKeyPath("readAccess.FLAGS.ItogType");
   if (type == null) {
     itogName = null;
     itogTitle = null;
     itogCount = null;
     canDelete = false;
     cantEdit = (Boolean) access.valueForKey("_create");
     // session().valueForKeyPath("readAccess._create.ItogType");
   } else {
     itogName = currType.name();
     itogTitle = currType.title();
     itogCount = currType.inYearCount();
     if (itogCount.intValue() == 0) itogCount = null;
     EOEditingContext ec = (EOEditingContext) valueForBinding("ec");
     NSArray itogs =
         EOUtilities.objectsMatchingKeyAndValue(
             ec, ItogContainer.ENTITY_NAME, ItogContainer.ITOG_TYPE_KEY, type);
     canDelete = (itogs == null || itogs.count() == 0);
     cantEdit = (Boolean) access.valueForKey("_edit");
     // session().valueForKeyPath("readAccess._edit.currType");
   }
   super.appendToResponse(aResponse, aContext);
 }
示例#13
0
 public org.pachyderm.foundation.eof.PDBScreen createEveryScreenRelationship() {
   EOEnterpriseObject eo =
       EOUtilities.createAndInsertInstance(
           editingContext(), org.pachyderm.foundation.eof.PDBScreen.ENTITY_NAME);
   addObjectToBothSidesOfRelationshipWithKey(eo, _PDBPresentation.EVERY_SCREEN_KEY);
   return (org.pachyderm.foundation.eof.PDBScreen) eo;
 }
 public static EOVPersonnelActuelEns createVPersonnelActuelEns(
     EOEditingContext editingContext, org.cocktail.feve.eos.modele.grhum.EOIndividu toIndividu) {
   EOVPersonnelActuelEns eo =
       (EOVPersonnelActuelEns)
           EOUtilities.createAndInsertInstance(editingContext, _EOVPersonnelActuelEns.ENTITY_NAME);
   eo.setToIndividuRelationship(toIndividu);
   return eo;
 }
示例#15
0
 public Group localInstanceIn(EOEditingContext editingContext) {
   Group localInstance = (Group) EOUtilities.localInstanceOfObject(editingContext, this);
   if (localInstance == null) {
     throw new IllegalStateException(
         "You attempted to localInstance " + this + ", which has not yet committed.");
   }
   return localInstance;
 }
 public static ERSyncClientDevice createERSyncClientDevice(
     EOEditingContext editingContext, Boolean disable, String name) {
   ERSyncClientDevice eo =
       (ERSyncClientDevice)
           EOUtilities.createAndInsertInstance(editingContext, _ERSyncClientDevice.ENTITY_NAME);
   eo.setDisable(disable);
   eo.setName(name);
   return eo;
 }
示例#17
0
 /** obtenir la valeur de la cle primaire a partir d'un Object quand celle-ci est cachee */
 public static Object primaryKeyForObject(
     EOEditingContext eContext, EOEnterpriseObject record, String primaryKeyName) {
   try {
     return EOUtilities.primaryKeyForObject(eContext, record).objectForKey(primaryKeyName);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }
示例#18
0
 protected static NSArray selectRawRowcourant(EOEditingContext ed) {
   NSArray result = null;
   try {
     result = EOUtilities.rawRowsForSQL(ed, "EtudiantEoGerry", sql.periodeCourante(), null);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return result;
 }
示例#19
0
 public static IndividuUlr localInstanceIn(EOEditingContext editingContext, IndividuUlr eo) {
   IndividuUlr localInstance =
       (eo == null) ? null : (IndividuUlr) EOUtilities.localInstanceOfObject(editingContext, eo);
   if (localInstance == null && eo != null) {
     throw new IllegalStateException(
         "You attempted to localInstance " + eo + ", which has not yet committed.");
   }
   return localInstance;
 }
 /**
  * A static factory method for creating a new UserMessageSubscription object given required
  * attributes and relationships.
  *
  * @param editingContext The context in which the new object will be inserted
  * @param isEnabledValue
  * @return The newly created object
  */
 public static UserMessageSubscription create(
     EOEditingContext editingContext, boolean isEnabledValue) {
   UserMessageSubscription eoObject =
       (UserMessageSubscription)
           EOUtilities.createAndInsertInstance(
               editingContext, _UserMessageSubscription.ENTITY_NAME);
   eoObject.setIsEnabled(isEnabledValue);
   return eoObject;
 }
示例#21
0
 public void takeValuesFromRequest(WORequest aRequest, WOContext aContext) {
   super.takeValuesFromRequest(aRequest, aContext);
   if (!Various.boolForObject(valueForBinding("showPopup"))) {
     selection =
         (PersonLink)
             EOUtilities.localInstanceOfObject(
                 ec, (EOEnterpriseObject) valueForBinding("selection"));
     //			syncSelection();
   }
 }
示例#22
0
 public static MovieRole createMovieRole(
     EOEditingContext editingContext,
     webobjectsexamples.businesslogic.movies.common.Movie movie,
     webobjectsexamples.businesslogic.movies.common.Talent talent) {
   MovieRole eo =
       (MovieRole) EOUtilities.createAndInsertInstance(editingContext, _MovieRole.ENTITY_NAME);
   eo.setMovieRelationship(movie);
   eo.setTalentRelationship(talent);
   return eo;
 }
 /**
  * Retrieve an object using a dictionary of keys and values to match.
  *
  * @param context The editing context to use
  * @param keysAndValues a dictionary of keys and values to match
  * @return the single entity that was retrieved, or null if there was none
  * @throws EOUtilities.MoreThanOneException if there is more than one matching object
  */
 public static UserMessageSubscription uniqueObjectMatchingValues(
     EOEditingContext context, NSDictionary<String, Object> keysAndValues)
     throws EOUtilities.MoreThanOneException {
   try {
     return (UserMessageSubscription)
         EOUtilities.objectMatchingValues(context, ENTITY_NAME, keysAndValues);
   } catch (EOObjectNotAvailableException e) {
     return null;
   }
 }
 public static ScolMaquetteAp localInstanceIn(EOEditingContext editingContext, ScolMaquetteAp eo) {
   ScolMaquetteAp localInstance =
       (eo == null)
           ? null
           : (ScolMaquetteAp) EOUtilities.localInstanceOfObject(editingContext, eo);
   if (localInstance == null && eo != null) {
     throw new IllegalStateException(
         "You attempted to localInstance " + eo + ", which has not yet committed.");
   }
   return localInstance;
 }
 public static ERSyncClientDevice localInstanceIn(
     EOEditingContext editingContext, ERSyncClientDevice eo) {
   ERSyncClientDevice localInstance =
       (eo == null)
           ? null
           : (ERSyncClientDevice) EOUtilities.localInstanceOfObject(editingContext, eo);
   if (localInstance == null && eo != null) {
     throw new IllegalStateException(
         "You attempted to localInstance " + eo + ", which has not yet committed.");
   }
   return localInstance;
 }
 public static TimePointApplication localInstanceIn(
     EOEditingContext editingContext, TimePointApplication eo) {
   TimePointApplication localInstance =
       (eo == null)
           ? null
           : (TimePointApplication) EOUtilities.localInstanceOfObject(editingContext, eo);
   if (localInstance == null && eo != null) {
     throw new IllegalStateException(
         "You attempted to localInstance " + eo + ", which has not yet committed.");
   }
   return localInstance;
 }
 public static EOVPersonnelActuelEns localInstanceIn(
     EOEditingContext editingContext, EOVPersonnelActuelEns eo) {
   EOVPersonnelActuelEns localInstance =
       (eo == null)
           ? null
           : (EOVPersonnelActuelEns) EOUtilities.localInstanceOfObject(editingContext, eo);
   if (localInstance == null && eo != null) {
     throw new IllegalStateException(
         "You attempted to localInstance " + eo + ", which has not yet committed.");
   }
   return localInstance;
 }
 public static TimePointApplication createTimePointApplication(
     EOEditingContext editingContext,
     Integer instanceWeight,
     com.dyned.woremotesiteconfig.eom.StoredApp storedApp,
     com.dyned.woremotesiteconfig.eom.TimePoint timePoint) {
   TimePointApplication eo =
       (TimePointApplication)
           EOUtilities.createAndInsertInstance(editingContext, _TimePointApplication.ENTITY_NAME);
   eo.setInstanceWeight(instanceWeight);
   eo.setStoredAppRelationship(storedApp);
   eo.setTimePointRelationship(timePoint);
   return eo;
 }
 /** retourne les individus enregistr�s comme contacts de l'entreprise fournisseur courante */
 public NSArray individusContactForFournis() {
   NSArray result;
   EOStructureUlr struct = structure();
   if (struct != null) {
     NSDictionary args = new NSDictionary(struct.cStructure(), "idStructure");
     result =
         EOUtilities.objectsWithFetchSpecificationAndBindings(
             editingContext(), "IndividuUlr", "individusContactForStructure", args);
   } else {
     result = new NSArray();
   }
   return result;
 }
示例#30
0
 public static PDBPresentation createPDBPresentation(
     EOEditingContext editingContext,
     String identifier,
     Integer pk,
     org.pachyderm.foundation.eof.PDBScreen primeScreen) {
   PDBPresentation eo =
       (PDBPresentation)
           EOUtilities.createAndInsertInstance(editingContext, _PDBPresentation.ENTITY_NAME);
   eo.setIdentifier(identifier);
   eo.setPk(pk);
   eo.setPrimeScreenRelationship(primeScreen);
   return eo;
 }