public NSArray repartValidations(EOQualifier qualifier, NSArray sortOrderings, boolean fetch) { NSArray results; if (fetch) { EOQualifier fullQualifier; EOQualifier inverseQualifier = new EOKeyValueQualifier( fr.univlr.cri.conges.eos.modele.conges.EORepartValidation.OCCUPATION_KEY, EOQualifier.QualifierOperatorEqual, this); if (qualifier == null) { fullQualifier = inverseQualifier; } else { NSMutableArray qualifiers = new NSMutableArray(); qualifiers.addObject(qualifier); qualifiers.addObject(inverseQualifier); fullQualifier = new EOAndQualifier(qualifiers); } results = fr.univlr.cri.conges.eos.modele.conges.EORepartValidation.fetchRepartValidations( editingContext(), fullQualifier, sortOrderings); } else { results = repartValidations(); if (qualifier != null) { results = (NSArray) EOQualifier.filteredArrayWithQualifier(results, qualifier); } if (sortOrderings != null) { results = (NSArray) EOSortOrdering.sortedArrayUsingKeyOrderArray(results, sortOrderings); } } return results; }
public NSArray tosIntervention(EOQualifier qualifier, NSArray sortOrderings, boolean fetch) { NSArray results; if (fetch) { EOQualifier fullQualifier; EOQualifier inverseQualifier = new EOKeyValueQualifier( org.cocktail.dt.server.metier.EOIntervention.TO_ACTIVITES_KEY, EOQualifier.QualifierOperatorEqual, this); if (qualifier == null) { fullQualifier = inverseQualifier; } else { NSMutableArray qualifiers = new NSMutableArray(); qualifiers.addObject(qualifier); qualifiers.addObject(inverseQualifier); fullQualifier = new EOAndQualifier(qualifiers); } results = org.cocktail.dt.server.metier.EOIntervention.fetchAll( editingContext(), fullQualifier, sortOrderings); } else { results = tosIntervention(); if (qualifier != null) { results = (NSArray) EOQualifier.filteredArrayWithQualifier(results, qualifier); } if (sortOrderings != null) { results = (NSArray) EOSortOrdering.sortedArrayUsingKeyOrderArray(results, sortOrderings); } } return results; }
public void initCustomerIssues() { EOFetchSpecification fs; NSDictionary bindings = null; Session s = (Session) session(); NSMutableArray qual = new NSMutableArray(); NSMutableArray qual1 = new NSMutableArray(); EOQualifier qualifier; // 'Open items' // qual.addObject(EOQualifier.qualifierWithQualifierFormat("bugStatus !='CLOSED'", null)); // qual.addObject(EOQualifier.qualifierWithQualifierFormat("bugStatus !='RESOLVED'", null)); // qual.addObject(EOQualifier.qualifierWithQualifierFormat("bugStatus !='VERIFIED'", null)); // Taser qual1.addObject(EOQualifier.qualifierWithQualifierFormat("type = 'Prospect'", null)); qual1.addObject(EOQualifier.qualifierWithQualifierFormat("type = 'Customer'", null)); qual.addObject(new EOOrQualifier(qual1)); // Single Customer if (customerId() != null) { qual.addObject(EOQualifier.qualifierWithQualifierFormat("bugId=" + customerId(), null)); showProductSelector = true; } else { // Products if (selectedProducts.count() == 1) { if (selectedProducts.contains("Trusted Access")) { qual.addObject( EOQualifier.qualifierWithQualifierFormat( "product.productName = 'Device: Trusted Access'", null)); } else if (selectedProducts.contains("Secure Storage")) { qual.addObject( EOQualifier.qualifierWithQualifierFormat( "product.productName = 'Device: Secure Storage'", null)); } } } Object orderings[] = { EOSortOrdering.sortOrderingWithKey("version", EOSortOrdering.CompareAscending), EOSortOrdering.sortOrderingWithKey("targetMilestone", EOSortOrdering.CompareAscending), EOSortOrdering.sortOrderingWithKey( "priority", EOSortOrdering.CompareCaseInsensitiveAscending), EOSortOrdering.sortOrderingWithKey( "bugSeverity", EOSortOrdering.CompareCaseInsensitiveAscending), }; fs = new EOFetchSpecification("Item", new EOAndQualifier(qual), new NSArray(orderings)); fs.setRefreshesRefetchedObjects(true); ((EODatabaseDataSource) customerIssueDisplayGroup.dataSource()).setFetchSpecification(fs); customerIssueDisplayGroup.fetch(); }
public NSArray primaryKeySupportStatementsForEntityGroups(NSArray entityGroups) { String primaryKeyTableName = ((JDBCAdaptor) this.adaptor()).plugIn().primaryKeyTableName(); NSMutableArray primaryKeyExpressions = new NSMutableArray(); primaryKeyExpressions.addObject( this._expressionForString( "CREATE TABLE " + primaryKeyTableName + " (NAME char(40), PK long)")); primaryKeyExpressions.addObject( this._expressionForString( "ALTER TABLE " + primaryKeyTableName + " ADD PRIMARY KEY (NAME)")); primaryKeyExpressions.addObject( this._expressionForString("CREATE UNIQUE INDEX " + primaryKeyTableName + " NAME")); return primaryKeyExpressions.immutableClone(); }
public NSArray customerIssues() { NSMutableArray allChildren = new NSMutableArray(); NSMutableArray qual = new NSMutableArray(); Item customer; Item child; if (customerIssues == null) { if (bugId() != null) { qual.addObject(EOQualifier.qualifierWithQualifierFormat("bugId=" + bugId(), null)); EOFetchSpecification spec = new EOFetchSpecification("Item", new EOAndQualifier(qual), null); // Perform actual fetch customerIssues = (NSArray) session().defaultEditingContext().objectsWithFetchSpecification(spec); } else { Enumeration enumer = ((NSArray) customerIssueDisplayGroup.allObjects()).objectEnumerator(); // For each Customer while (enumer.hasMoreElements()) { customer = (Item) enumer.nextElement(); NSArray children = (NSArray) customer.valueForKey("allChildren"); // Add all of their issues (if they haven't been added already Enumeration enumer2 = children.objectEnumerator(); while (enumer2.hasMoreElements()) { child = (Item) enumer2.nextElement(); if (!allChildren.contains(child)) { allChildren.addObject(child); } } } Object orderings[] = { EOSortOrdering.sortOrderingWithKey("version", EOSortOrdering.CompareAscending), EOSortOrdering.sortOrderingWithKey("targetMilestone", EOSortOrdering.CompareAscending), EOSortOrdering.sortOrderingWithKey( "priority", EOSortOrdering.CompareCaseInsensitiveAscending), EOSortOrdering.sortOrderingWithKey( "bugSeverity", EOSortOrdering.CompareCaseInsensitiveAscending), }; // Sort the issues customerIssues = EOSortOrdering.sortedArrayUsingKeyOrderArray(allChildren, new NSArray(orderings)); } } return customerIssues; }
public NSArray statementsToDropPrimaryKeyConstraintsOnEntityGroups( NSArray entityGroups, EOSchemaSynchronizationModelChanges changes, EOSchemaGenerationOptions options) { if (entityGroups == null) return NSArray.EmptyArray; if (changes == null) changes = newChanges(); NSMutableArray expressions = new NSMutableArray(); for (Enumeration enumerator = entityGroups.objectEnumerator(); enumerator.hasMoreElements(); ) { NSArray entities = (NSArray) enumerator.nextElement(); EOEntity _last = (EOEntity) entities.lastObject(); // only need entity to get the table name for the group String nameInObjectStore = _nameInObjectStoreForEntityGroupWithChangeDictionary( entities, changes.changesForTableNamed(_last.externalName())); if ((nameInObjectStore != null) && (!"".equals(nameInObjectStore))) { expressions.addObject( this._expressionForString( "delete from _SYS_RELATIONSHIP where source_table = '" + nameInObjectStore + "' or dest_table = '" + nameInObjectStore + "'")); } } return expressions.immutableClone(); }
/** * Overrides the parent implementation to provide a more efficient mechanism for generating * primary keys, while generating the primary key support on the fly. * * @param count the batch size * @param entity the entity requesting primary keys * @param channel open JDBCChannel * @return NSArray of NSDictionary where each dictionary corresponds to a unique primary key value */ public NSArray newPrimaryKeys(int count, EOEntity entity, JDBCChannel channel) { if (isPrimaryKeyGenerationNotSupported(entity)) { return null; } EOAttribute attribute = (EOAttribute) entity.primaryKeyAttributes().lastObject(); String attrName = attribute.name(); boolean isIntType = "i".equals(attribute.valueType()); NSMutableArray results = new NSMutableArray(count); String sequenceName = sequenceNameForEntity(entity); DB2Expression expression = new DB2Expression(entity); boolean succeeded = false; for (int tries = 0; !succeeded && tries < 2; tries++) { while (results.count() < count) { try { StringBuffer sql = new StringBuffer(); sql.append("SELECT "); sql.append("next value for " + sequenceName + " AS KEY"); sql.append(" from sysibm.sysdummy1"); expression.setStatement(sql.toString()); channel.evaluateExpression(expression); try { NSDictionary row; while ((row = channel.fetchRow()) != null) { Enumeration pksEnum = row.allValues().objectEnumerator(); while (pksEnum.hasMoreElements()) { Number pkObj = (Number) pksEnum.nextElement(); Number pk; if (isIntType) { pk = Integer.valueOf(pkObj.intValue()); } else { pk = Long.valueOf(pkObj.longValue()); } results.addObject(new NSDictionary(pk, attrName)); } } } finally { channel.cancelFetch(); } succeeded = true; } catch (JDBCAdaptorException ex) { throw ex; } } } if (results.count() != count) { throw new IllegalStateException( "Unable to generate primary keys from the sequence for " + entity + "."); } return results; }
// ---------------------------------------------------------- private NSArray<Submission> extractSubmissions(NSArray<UserSubmissionPair> userSubs) { NSMutableArray<Submission> submissions = new NSMutableArray<Submission>(); for (UserSubmissionPair pair : userSubs) { if (pair.userHasSubmission()) { submissions.addObject(pair.submission()); } } return submissions; }
public NSArray statementsToImplementPrimaryKeyConstraintsOnEntityGroups( NSArray entityGroups, EOSchemaSynchronizationModelChanges changes, EOSchemaGenerationOptions options) { NSArray primaryKeyExpressions = this.primaryKeyConstraintStatementsForEntityGroups(entityGroups); NSMutableArray createStatements = new NSMutableArray(); NSMutableArray otherStatements = new NSMutableArray(); for (Enumeration enumerator = primaryKeyExpressions.objectEnumerator(); enumerator.hasMoreElements(); ) { EOSQLExpression expression = (EOSQLExpression) enumerator.nextElement(); String statement = expression.statement(); if (statement.startsWith("create")) { createStatements.addObject(expression); } else if (!statement.startsWith("delete from _SYS_RELATIONSHIP")) { otherStatements.addObject(expression); } } return createStatements.arrayByAddingObjectsFromArray(otherStatements); }
public NSArray<edu.umich.marketplace.eof.Advert> adverts( EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings, boolean fetch) { NSArray<edu.umich.marketplace.eof.Advert> results; if (fetch) { EOQualifier fullQualifier; EOQualifier inverseQualifier = new EOKeyValueQualifier( edu.umich.marketplace.eof.Advert.CATEGORY_KEY, EOQualifier.QualifierOperatorEqual, this); if (qualifier == null) { fullQualifier = inverseQualifier; } else { NSMutableArray qualifiers = new NSMutableArray(); qualifiers.addObject(qualifier); qualifiers.addObject(inverseQualifier); fullQualifier = new EOAndQualifier(qualifiers); } results = edu.umich.marketplace.eof.Advert.fetchAdverts( editingContext(), fullQualifier, sortOrderings); } else { results = adverts(); if (qualifier != null) { results = (NSArray<edu.umich.marketplace.eof.Advert>) EOQualifier.filteredArrayWithQualifier(results, qualifier); } if (sortOrderings != null) { results = (NSArray<edu.umich.marketplace.eof.Advert>) EOSortOrdering.sortedArrayUsingKeyOrderArray(results, sortOrderings); } } return results; }
public NSArray<er.sync.eo.ERSyncPrincipal> principals( EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings, boolean fetch) { NSArray<er.sync.eo.ERSyncPrincipal> results; if (fetch) { EOQualifier fullQualifier; EOQualifier inverseQualifier = new EOKeyValueQualifier( er.sync.eo.ERSyncPrincipal.DEVICE_TYPE_KEY, EOQualifier.QualifierOperatorEqual, this); if (qualifier == null) { fullQualifier = inverseQualifier; } else { NSMutableArray qualifiers = new NSMutableArray(); qualifiers.addObject(qualifier); qualifiers.addObject(inverseQualifier); fullQualifier = new EOAndQualifier(qualifiers); } results = er.sync.eo.ERSyncPrincipal.fetchERSyncPrincipals( editingContext(), fullQualifier, sortOrderings); } else { results = principals(); if (qualifier != null) { results = (NSArray<er.sync.eo.ERSyncPrincipal>) EOQualifier.filteredArrayWithQualifier(results, qualifier); } if (sortOrderings != null) { results = (NSArray<er.sync.eo.ERSyncPrincipal>) EOSortOrdering.sortedArrayUsingKeyOrderArray(results, sortOrderings); } } return results; }
// High level all for top dictionary public NSMutableDictionary thePlotData() { NSMutableDictionary myPlot = new NSMutableDictionary(); NSMutableArray subPlotDict = new NSMutableArray(); Enumeration enumer = plots.objectEnumerator(); while (enumer.hasMoreElements()) { SubPlot currSubPlot = (SubPlot) enumer.nextElement(); subPlotDict.addObject(currSubPlot.toDictionary()); } // Title = "Defect Trends"; if (title != null) { myPlot.setObjectForKey(title, "Title"); } myPlot.setObjectForKey(subPlotDict, "Plots"); return (myPlot); }
public NSArray itemsWithMultipleParents() { if (itemsWithMultipleParents == null) { NSMutableArray temp = new NSMutableArray(); Enumeration enumer = customerIssues().objectEnumerator(); while (enumer.hasMoreElements()) { Item taserIssue = (Item) enumer.nextElement(); NSArray parents = (NSArray) taserIssue.topMostParents(); // will get some non-taser parents. if ((parents != null) && (parents.count() > 1)) { temp.addObject(taserIssue); } } itemsWithMultipleParents = new NSArray(temp); } return itemsWithMultipleParents; }
public NSArray topMostTaserParents() { Enumeration enumer = anItem.topMostParents().objectEnumerator(); NSMutableArray temp = new NSMutableArray(); // System.out.println("Item - " + anItem.valueForKey("bugId") + " - " + anItem.shortDesc()); while (enumer.hasMoreElements()) { Item tempEo = (Item) enumer.nextElement(); // System.out.println("\t\tparentA - " + tempEo.bugId() + " - " + tempEo.shortDesc()); if ((tempEo.type().equals("Prospect")) || (tempEo.type().equals("Customer"))) { temp.addObject(tempEo); // System.out.println("\t\tparentB - " + tempEo.bugId() + " - " + tempEo.shortDesc()); } } return temp; }
public NSArray personList() { NSArray forcedList = (NSArray) valueForBinding("forcedList"); NSMutableArray result = (forcedList == null) ? new NSMutableArray() : EOUtilities.localInstancesOfObjects(ec, forcedList).mutableClone(); NSArray personList = (NSArray) session().valueForKey("personList"); if (personList != null && personList.count() > 0) { Enumeration enu = personList.objectEnumerator(); while (enu.hasMoreElements()) { EOEnterpriseObject pers = (EOEnterpriseObject) enu.nextElement(); if (!result.contains(pers) && (entity().equals(pers.entityName()) || pers.entityName().equals(alterEntity()))) result.addObject(pers); } } return result; }
public void invalidateObjects(NSArray pObjects) { // System.out.println("ReleasePlan.invalidateObjects()"); // Invalidate Objects if (pObjects != null) { // System.out.println("ReleasePlan.invalidateObjects() - 2"); Enumeration enumer = pObjects.objectEnumerator(); NSMutableArray temp = new NSMutableArray(); while (enumer.hasMoreElements()) { Item i = (Item) enumer.nextElement(); i.invalidateAllChildren(); EOGlobalID id = (EOGlobalID) (session().defaultEditingContext().globalIDForObject(i)); if (id != null) { temp.addObject(id); } } session().defaultEditingContext().invalidateObjectsWithGlobalIDs((NSArray) temp); } }
public static void initColors() { if (theColors == null) { theColors = new NSMutableArray(); } if (theColors.count() == 0) { String[] aColor = {"0", "0", "255"}; NSArray theColor = new NSArray(aColor); theColors.addObject(theColor); String[] bColor = {"255", "0", "0"}; theColor = new NSArray(bColor); theColors.addObject(theColor); String[] cColor = {"0", "255", "0"}; theColor = new NSArray(cColor); theColors.addObject(theColor); String[] dColor = {"255", "0", "255"}; theColor = new NSArray(dColor); theColors.addObject(theColor); String[] eColor = {"0", "0", "0"}; theColor = new NSArray(eColor); theColors.addObject(theColor); String[] fColor = {"125", "0", "50"}; theColor = new NSArray(fColor); theColors.addObject(theColor); String[] gColor = {"50", "125", "0"}; theColor = new NSArray(gColor); theColors.addObject(theColor); String[] hColor = {"50", "0", "125"}; theColor = new NSArray(hColor); theColors.addObject(theColor); } }
public NSArray primaryKeyConstraintStatementsForEntityGroup(NSArray entityGroup) { if (entityGroup == null) return NSArray.EmptyArray; NSMutableDictionary columnNameDictionary = new NSMutableDictionary(); NSMutableArray primaryKeyConstraintExpressions = new NSMutableArray(); for (Enumeration enumerator = entityGroup.objectEnumerator(); enumerator.hasMoreElements(); ) { EOEntity entity = (EOEntity) enumerator.nextElement(); String tableName = entity.externalName(); NSArray primaryKeyAttributes = entity.primaryKeyAttributes(); boolean singlePrimaryKey = primaryKeyAttributes.count() == 1; if ((tableName != null) && (!"".equals(tableName)) && (primaryKeyAttributes.count() > 0)) { NSArray expressions = super.primaryKeyConstraintStatementsForEntityGroup(entityGroup); if ((expressions != null) && (expressions.count() > 0)) primaryKeyConstraintExpressions.addObjectsFromArray(expressions); for (Enumeration attributeEnumerator = primaryKeyAttributes.objectEnumerator(); attributeEnumerator.hasMoreElements(); ) { String columnName = ((EOAttribute) attributeEnumerator.nextElement()).columnName(); columnNameDictionary.setObjectForKey( columnName, entity.externalName() + "." + columnName); EOSQLExpression expression = this._expressionForString( "create " + (singlePrimaryKey ? "unique" : "") + " index " + entity.externalName() + " " + columnName); if (expression != null) primaryKeyConstraintExpressions.addObject(expression); } } } for (Enumeration enumerator = entityGroup.objectEnumerator(); enumerator.hasMoreElements(); ) { EOEntity entity = (EOEntity) enumerator.nextElement(); String tableName = entity.externalName(); if ((tableName != null) && (!"".equals(tableName))) { for (Enumeration relationshipEnumerator = entity.relationships().objectEnumerator(); relationshipEnumerator.hasMoreElements(); ) { EORelationship relationship = (EORelationship) relationshipEnumerator.nextElement(); if (!relationship.isFlattened()) { NSArray destinationAttributes = relationship.destinationAttributes(); // First exclude all the destination entity primary keys for (Enumeration attributeEnumerator = relationship.destinationEntity().primaryKeyAttributes().objectEnumerator(); attributeEnumerator.hasMoreElements(); ) { EOAttribute attribute = (EOAttribute) attributeEnumerator.nextElement(); columnNameDictionary.setObjectForKey( attribute.columnName(), relationship.destinationEntity().externalName() + "." + attribute.columnName()); } // Then deal with our end of things for (Enumeration attributeEnumerator = relationship.sourceAttributes().objectEnumerator(); attributeEnumerator.hasMoreElements(); ) { EOAttribute attribute = (EOAttribute) attributeEnumerator.nextElement(); if ((!this.isSinglePrimaryKeyAttribute(attribute)) && (columnNameDictionary.objectForKey(tableName + "." + attribute.columnName()) != null)) { columnNameDictionary.setObjectForKey( attribute.columnName(), tableName + "." + attribute.columnName()); EOSQLExpression expression = this._expressionForString( "create index " + tableName + " " + attribute.columnName()); if (expression != null) primaryKeyConstraintExpressions.addObject(expression); } } // Then deal with the other side if (entity.model() == relationship.destinationEntity().model()) { for (Enumeration attributeEnumerator = relationship.destinationAttributes().objectEnumerator(); attributeEnumerator.hasMoreElements(); ) { EOAttribute attribute = (EOAttribute) attributeEnumerator.nextElement(); String destinationTableName = relationship.destinationEntity().externalName(); if ((destinationTableName != null) && (!"".equals(destinationTableName))) { if ((!this.isSinglePrimaryKeyAttribute(attribute)) && (columnNameDictionary.objectForKey( destinationTableName + "." + attribute.columnName()) != null)) { columnNameDictionary.setObjectForKey( attribute.columnName(), destinationTableName + "." + attribute.columnName()); EOSQLExpression expression = this._expressionForString( "create index " + destinationTableName + " " + attribute.columnName()); if (expression != null) primaryKeyConstraintExpressions.addObject(expression); } if ((!relationship.isCompound()) && (relationship.sourceAttributes().count() == 1) && (relationship.destinationAttributes().count() == 1)) { String semantics; switch (relationship.joinSemantic()) { case EORelationship.FullOuterJoin: // '\001' case EORelationship.LeftOuterJoin: // '\002' case EORelationship.RightOuterJoin: // '\003' semantics = "*"; break; default: semantics = "="; break; } String sourceColumn = ((EOAttribute) relationship.sourceAttributes().objectAtIndex(0)) .columnName(); String destinationColumn = ((EOAttribute) relationship.destinationAttributes().objectAtIndex(0)) .columnName(); EOSQLExpression expression = this._expressionForString( "delete from _SYS_RELATIONSHIP where relationshipName = '" + relationship.name() + "' and source_table = '" + tableName + "' "); if (expression != null) primaryKeyConstraintExpressions.addObject(expression); expression = this._expressionForString( "insert into _SYS_RELATIONSHIP (relationshipName, source_table, source_column, dest_table, dest_column, operator, one_to_many) values ('" + relationship.name() + "','" + tableName + "','" + sourceColumn + "','" + destinationTableName + "','" + destinationColumn + "','" + semantics + "'," + (relationship.isToMany() ? 1 : 0) + ")"); if (expression != null) primaryKeyConstraintExpressions.addObject(expression); } } } } } } } } return primaryKeyConstraintExpressions.immutableClone(); }
// This adds the subplot to the plots dictionary before returning it. public SubPlot newSubPlot() { SubPlot theSubPlot = new SubPlot(); plots.addObject(theSubPlot); return theSubPlot; }
public void addToPlots(SubPlot theSubPlot) { plots.addObject(theSubPlot); }