public WOComponent deleteStudent() { EOEditingContext context = session().defaultEditingContext(); // delete selected object context.deleteObject(student); saveChanges(); return null; }
public static void invalidateObjects(EOEditingContext ec, NSArray list) { NSMutableArray listGIDs = new NSMutableArray(); for (int i = 0; i < list.count(); i++) { listGIDs.addObject(ec.globalIDForObject((EOEnterpriseObject) list.objectAtIndex(i))); } ec.invalidateObjectsWithGlobalIDs(listGIDs); }
private File _call() { // If development if (ERXApplication.isDevelopmentModeSafe()) { parameters.put("_isDevelopmentMode", Boolean.TRUE); } else { parameters.put("_isDevelopmentMode", Boolean.FALSE); } reportFile = null; if (log.isDebugEnabled()) log.debug("Starting JasperReportTask: " + toString()); EOEditingContext ec = ERXEC.newEditingContext(); ec.lock(); try { @SuppressWarnings("unchecked") NSArray<EOEnterpriseObject> objects = ec.objectsWithFetchSpecification(fetchSpecification); jrDataSource = new ERJRFoundationDataSource(objects); if (jasperCompiledReportFileName != null) { reportFile = ERJRUtilities.runCompiledReportToPDFFile( jasperCompiledReportFileName, frameworkName, parameters, jrDataSource); } } catch (Exception e) { throw new NestableRuntimeException(e); } finally { ec.unlock(); } return reportFile; }
public WOComponent selectStudent() { EOEditingContext context = session().defaultEditingContext(); context.revert(); student = selectedStudent; homeAddress = (HomeAddress) student.address(); return null; }
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; }
@Override public WOActionResults performAction() { log.debug("The result of the task was " + _result); if (_nextPage != null && _nextPageResultKey != null) { if (_result instanceof EOGlobalID) { // Inflate it to a fault EOEditingContext ec = ERXEC.newEditingContext(); // Let's ensure fresh ec since we are likely coming out of a background task ec.setFetchTimestamp(System.currentTimeMillis()); _result = ec.faultForGlobalID((EOGlobalID) _result, ec); } _nextPage.takeValueForKey(_result, _nextPageResultKey); } if (_nextPage != null && _nextPageValues != null) { for (String key : nextPageValues().allKeys()) { Object value = nextPageValues().valueForKey(key); _nextPage.takeValueForKey(value, key); } } if (_nextPage != null && _nextPage instanceof IERXRefreshPage) { ((IERXRefreshPage) _nextPage).refresh(); } return _nextPage; }
public ERJRFetchSpecificationReportTask( EOFetchSpecification fetchSpecification, String jasperCompiledReportFileName, String frameworkName, HashMap<String, Object> parameters) { ERXAssert.PRE.notNull(fetchSpecification); ERXAssert.PRE.notNull(jasperCompiledReportFileName); // Since it is likely the fetch spec will be used in a different // background thread during report generation, we need to ensure we have a schema-based // qualifier instead of a memory-based qualifier that might have references to EOs // in an RR-locked editing context EOFetchSpecification fs = null; EOEditingContext ec = ERXEC.newEditingContext(); ec.lock(); try { fs = schemaBasedFetchSpecification(fetchSpecification); } catch (Exception e) { throw new RuntimeException("Failed to convert fetchSpecification to schema-based", e); } finally { ec.unlock(); } this.fetchSpecification = fs; this.jasperCompiledReportFileName = jasperCompiledReportFileName; this.frameworkName = frameworkName; this.parameters = parameters; if (this.parameters == null) { this.parameters = new HashMap<String, Object>(); } }
// CLAUSE WHERE "UV.ANUNIV || UV.PRDUNIV = ... AND UV.UVC = ... // AND UV.ANUNIV || UV.PRDUNIV = EIA.ANUNIV || EIA.PRDUNIV" UV o� est // inscris l'�tudiant private static EOQualifier qualForUv(String uv, String periode) { // ARGSUV.addObject(uv); NSMutableArray quals = new NSMutableArray(); EOEditingContext myContext = ERXEC.newEditingContext(); EOQualifier qalUv = EOVueInsuv.UVC .eq(uv) .and( EOVueInsuv.EO_ETUDIANT_INSCR_ADM .dot(EOEtudiantInscrAdm.ETU_ID) .eq(EOVueInsuv.ETU_ID)); quals.addObject(qalUv); if (periode != null) { EOQualifier qualPer = EOQualifier.qualifierWithQualifierFormat("anUniv=%@ AND prdUniv=%@", ARGSUV); quals.addObject(qualPer); } EOFetchSpecification spec = null; if (quals.count() == 2) { EOQualifier qual = new EOAndQualifier(quals); spec = new EOFetchSpecification("EOVueInsuv", qual, null); } else { spec = new EOFetchSpecification("EOVueInsuv", qalUv, null); } spec.setUsesDistinct(true); NSArray uvs = myContext.objectsWithFetchSpecification(spec); NSMutableArray etuids = new NSMutableArray(); for (int i = 0; i < uvs.count(); i++) { EOVueInsuv luv = (EOVueInsuv) uvs.objectAtIndex(i); Long etu_id = luv.etuId(); etuids.addObject(etu_id); } EOQualifier fin = ETU_INSCR_ADMS.dot(EOEtudiantInscrAdm.ETU_ID).in(etuids.immutableClone()); return fin; }
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"); }
// ON veut ajouter ces diplome à la liste des diplomes sans RN... public void ajouterRestriction(NSArray listeDipl) { EOEditingContext ec = maSession.defaultEditingContext(); boolean travail = false; Enumeration e = listeDipl.objectEnumerator(); while (e.hasMoreElements()) { EOGenericRecord diplSel = (EOGenericRecord) e.nextElement(); // NSLog.out.appendln("A virer : "+diplSel.valueForKey("diplome")); // Pas déjà ? Integer fspnKey = (Integer) diplSel.valueForKey("fspnKey"); if (listeEOipDiplSansRn.objectForKey(fspnKey) == null) { IpDiplSansRn eoAAjouter = new IpDiplSansRn(); eoAAjouter.setFannKey((Number) diplSel.valueForKey("fannKey")); eoAAjouter.setFspnKey((Number) fspnKey); travail = true; ec.insertObject(eoAAjouter); listeEOipDiplSansRn.setObjectForKey(eoAAjouter, fspnKey); } } if (travail) { ec.saveChanges(); chargerDiplRN(); } }
public void initListeDiplRN() { chargerDiplRN(); // On va se construire un dico des enreg. pour l'année en cours de IP_DIPL_SANS_RN... NSArray bindings = new NSArray(new Object[] {getFannKey()}); EOQualifier qualifier = EOQualifier.qualifierWithQualifierFormat("fannKey = %@", bindings); // la liste des diplomes qui n'autorisent pas les RN par le Web EOFetchSpecification fetchSpec = new EOFetchSpecification("IpDiplSansRn", qualifier, null); fetchSpec.setRefreshesRefetchedObjects(true); EOEditingContext ec = maSession.defaultEditingContext(); NSArray res = ec.objectsWithFetchSpecification(fetchSpec); listeEOipDiplSansRn = new NSMutableDictionary(); if (res != null && res.count() > 0) { Enumeration e = res.objectEnumerator(); while (e.hasMoreElements()) { IpDiplSansRn eoIpDiplSansRN = (IpDiplSansRn) e.nextElement(); Integer fspnKey = (Integer) eoIpDiplSansRN.fspnKey(); listeEOipDiplSansRn.setObjectForKey(eoIpDiplSansRN, fspnKey); } } }
/** Go back to administration page */ public AdministrationPage administrationPage() { AdministrationPage nextPage = (AdministrationPage) pageWithName("AdministrationPage"); EOEditingContext context = session().defaultEditingContext(); // throw away any unsaved changes context.revert(); return nextPage; }
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; }
/** retourne l'objet du globalID s'il existe, sinon son fault */ public static EOGenericRecord safeObjectForGlobalID(EOEditingContext eContext, EOGlobalID gid) { EOGenericRecord objFault; objFault = (EOGenericRecord) eContext.objectForGlobalID(gid); if (objFault != null) { return objFault; } else { return (EOGenericRecord) eContext.faultForGlobalID(gid, eContext); } }
public void createDummyData() { ec = ERXEC.newEditingContext(); ec.lock(); try { doCreateDummyData(); } finally { ec.unlock(); } }
public void cancel() { ec.revert(); // NSDictionary snapshot = ec.committedSnapshotForObject(onEdit); if (ec.insertedObjects().contains(item)) { NSMutableArray fullList = (NSMutableArray) session().valueForKey("personList"); fullList.removeObject(item); } // onEdit = null; }
public void createTables() { ec = ERXEC.newEditingContext(); ec.lock(); try { boolean dropTables = ERXProperties.booleanForKeyWithDefault("dropTables", true); createTables(dropTables); } finally { ec.unlock(); } }
/** * Action called when an upload succeeds * * @return results of the */ public WOActionResults uploadSucceededAction() { EOEditingContext workingEC = masterObject().editingContext(); ERAttachment existing = (ERAttachment) masterObject().valueForKey(relationshipKey()); if (existing != null) { workingEC.deleteObject(existing.localInstanceIn(workingEC)); } masterObject().addObjectToBothSidesOfRelationshipWithKey(newAttachment(), relationshipKey()); _showUpload = false; return (WOActionResults) valueForBinding(Keys.uploadSucceededAction); }
/*------------------------------------------------------------------------------------------------* * Overridden by subclasses to perform additional initialization on the receiver upon its being * inserted into EOEditingContext. This is commonly used to assign default values or record the * time of insertion. EOCustomObject's implementation merely sends an awakeObjectFromInsertion * to the receiver's EOClassDescription. * * Subclasses should invoke super's implementation before performing their own initialization. *------------------------------------------------------------------------------------------------*/ @Override public void awakeFromInsertion(EOEditingContext ec) { super.awakeFromInsertion(ec); LOG.info( "-----> awakeFromInsert: ({}) EOs: ({}), +({}), ~({}), -({})", ec, ec.registeredObjects().count(), ec.insertedObjects().count(), ec.updatedObjects().count(), ec.deletedObjects().count()); }
/** Deletes the current component */ public WOComponent deleteComponent() { EOEditingContext ec = session().defaultEditingContext(); Enumeration<SWPictureLink> e = currentComponent.swPictureLinks().objectEnumerator(); while (e.hasMoreElements()) { ec.deleteObject(e.nextElement()); } selectedPage.removeComponent(currentComponent); ec.deleteObject(currentComponent); ec.saveChanges(); return null; }
private static EOTypeGroupe localInstanceOfObject(EOEditingContext ec, EOTypeGroupe object) { if (object != null && ec != null) { EOEditingContext otherEditingContext = object.editingContext(); if (otherEditingContext == null) { throw new IllegalArgumentException( "The EOTypeGroupe " + object + " is not in an EOEditingContext."); } else { com.webobjects.eocontrol.EOGlobalID globalID = otherEditingContext.globalIDForObject(object); return (EOTypeGroupe) ec.faultForGlobalID(globalID, ec); } } else { return null; } }
/** * Internal method that handles prefetching of to-many relationships.<br> * // TBD This is a workaround to what looks like a bug in WO 5.1 & WO 5.2. Remove as soon as it's * no longer needed * * <p>The problem is that even refreshing fetches don't refresh the to-many relationships they * prefetch. */ public void _followToManyRelationshipWithFetchSpecification( EORelationship relationship, EOFetchSpecification fetchspecification, NSArray objects, EOEditingContext editingcontext) { int count = objects.count(); for (int i = 0; i < count; i++) { EOEnterpriseObject object = (EOEnterpriseObject) objects.objectAtIndex(i); EOGlobalID sourceGlobalID = editingcontext.globalIDForObject(object); String relationshipName = relationship.name(); if (!object.isFault()) { EOFaulting toManyArray = (EOFaulting) object.storedValueForKey(relationshipName); if (!toManyArray.isFault()) { EOFaulting tmpToManyArray = (EOFaulting) arrayFaultWithSourceGlobalID(sourceGlobalID, relationshipName, editingcontext); // Turn the existing array back into a fault by assigning it // the fault handler of the newly created fault toManyArray.turnIntoFault(tmpToManyArray.faultHandler()); } } } super._followToManyRelationshipWithFetchSpecification( relationship, fetchspecification, objects, editingcontext); }
public static NSArray<edu.umich.marketplace.eof.Category> fetchTopCategories( EOEditingContext editingContext) { EOFetchSpecification fetchSpec = EOFetchSpecification.fetchSpecificationNamed("topCategories", "Category"); return (NSArray<edu.umich.marketplace.eof.Category>) editingContext.objectsWithFetchSpecification(fetchSpec); }
public static ScolMaquetteAp createScolMaquetteAp( EOEditingContext editingContext, Long mapGroupePrevu, Long mapGroupeReel, String mapLibelle, String mapLibelleReel, Long mapSeuil, java.math.BigDecimal mapValeur, String mhcoCode, org.cocktail.groupescol.client.eof.VScolMaquetteApEc vScolMaquetteApEc, org.cocktail.groupescol.client.eof.VSemestreAp vSemestreAp) { ScolMaquetteAp eo = null; EOClassDescription classDescription = EOClassDescription.classDescriptionForEntityName(_ScolMaquetteAp.ENTITY_NAME); if (classDescription == null) { throw new IllegalArgumentException( "Could not find EOClassDescription for entity name '" + _ScolMaquetteAp.ENTITY_NAME + "' !"); } else { eo = (ScolMaquetteAp) classDescription.createInstanceWithEditingContext(editingContext, null); editingContext.insertObject(eo); } eo.setMapGroupePrevu(mapGroupePrevu); eo.setMapGroupeReel(mapGroupeReel); eo.setMapLibelle(mapLibelle); eo.setMapLibelleReel(mapLibelleReel); eo.setMapSeuil(mapSeuil); eo.setMapValeur(mapValeur); eo.setMhcoCode(mhcoCode); eo.setVScolMaquetteApEcRelationship(vScolMaquetteApEc); eo.setVSemestreApRelationship(vSemestreAp); return eo; }
public Main(WOContext context) { super(context); // The memory leak doesn't happen unless there are multiple OSCs registered with // ERXObjectStoreCoordinatorSynchronizer._coordinators. Using an OSC (performing a lookup, etc, // as below) causes the OSC to be added to the _coordinators array. EOEditingContext ec = ERXEC.newEditingContext(_osc); ec.lock(); try { NSArray dcArray = EOUtilities.objectsForEntityNamed(ec, "DataContainer"); } finally { ec.unlock(); ec.dispose(); ec = null; } }
/** retourne les globalIDs des objets */ public static NSArray globalIDsForObjects(EOEditingContext eContext, NSArray objects) { NSMutableArray gids = new NSMutableArray(); for (int i = 0; i < objects.count(); i++) { gids.addObject(eContext.globalIDForObject((EOEnterpriseObject) objects.objectAtIndex(i))); } return gids; }
/** retourne des faults d'objets à partir des globalIDs */ public static NSArray faultsForGlobalIDs(EOEditingContext eContext, NSArray ids) { NSMutableArray objects = new NSMutableArray(); for (int i = 0; i < ids.count(); i++) { objects.addObject(eContext.faultForGlobalID((EOGlobalID) ids.objectAtIndex(i), eContext)); } return objects; }
/** cree une instance de l'enregistrement d'entite entity et avec l'editingContext eContext */ public static EOGenericRecord getInstance(EOEditingContext eContext, String entity) { EOClassDescription descriptionClass = EOClassDescription.classDescriptionForEntityName(entity); EOGenericRecord instance = (EOGenericRecord) descriptionClass.createInstanceWithEditingContext(eContext, null); eContext.insertObject(instance); return instance; }
@Override protected void handleUnsuccessfullQueryForKey(Object key) { EOEditingContext ec = ERXEC.newEditingContext(); EOGlobalID gid = NO_GID_MARKER; ec.lock(); try { EOEnterpriseObject eo = (EOEnterpriseObject) EOUtilities.objectsMatchingKeyAndValue(ec, ENTITY, Key.KEY, key).lastObject(); if (eo != null) { gid = ec.globalIDForObject(eo); } } finally { ec.unlock(); } cache().setObjectForKey(createRecord(gid, null), key); }
public static NSArray fetchIndividuUlrs( EOEditingContext editingContext, EOQualifier qualifier, NSArray sortOrderings) { EOFetchSpecification fetchSpec = new EOFetchSpecification(_IndividuUlr.ENTITY_NAME, qualifier, sortOrderings); fetchSpec.setIsDeep(true); NSArray eoObjects = (NSArray) editingContext.objectsWithFetchSpecification(fetchSpec); return eoObjects; }