Exemplo n.º 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;
 }
Exemplo n.º 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;
  }
Exemplo n.º 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");
 }
Exemplo n.º 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;
  }
Exemplo n.º 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");
 }
Exemplo n.º 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();
      }
    }
  }
Exemplo n.º 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;
 }
Exemplo n.º 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;
   }
 }
Exemplo n.º 10
0
 public NSArray faxFournis() {
   NSDictionary args = new NSDictionary(persId(), "persId");
   NSArray results =
       EOUtilities.objectsWithFetchSpecificationAndBindings(
           editingContext(), "PersonneTelephone", "faxForPersId", args);
   return EOPersonneTelephone.prepareFetchResultForDisplay(results, false);
 }
Exemplo n.º 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;
  }
Exemplo n.º 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);
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 20
0
 /**
  * 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;
 }
Exemplo n.º 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();
   }
 }
Exemplo n.º 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;
 }
Exemplo n.º 23
0
 /**
  * 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;
   }
 }
Exemplo n.º 24
0
 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;
 }
Exemplo n.º 29
0
 /** 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;
 }
Exemplo n.º 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;
 }