List of usage examples for java.util Set equals
boolean equals(Object o);
From source file:com.duowan.common.spring.jdbc.BeanPropertyRowMapper.java
/** * Extract the values for all columns in the current row. * <p>Utilizes public setters and result set metadata. * @see java.sql.ResultSetMetaData//from ww w.j a v a 2 s .c o m */ public T mapRow(ResultSet rs, int rowNumber) throws SQLException { Assert.state(this.mappedClass != null, "Mapped class was not specified"); T mappedObject = BeanUtils.instantiate(this.mappedClass); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(mappedObject); initBeanWrapper(bw); ResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount(); Set<String> populatedProperties = (isCheckFullyPopulated() ? new HashSet<String>() : null); for (int index = 1; index <= columnCount; index++) { String column = JdbcUtils.lookupColumnName(rsmd, index); PropertyDescriptor pd = this.mappedFields.get(column.replaceAll(" ", "").toLowerCase()); if (pd != null) { try { Object value = getColumnValue(rs, index, pd); if (logger.isDebugEnabled() && rowNumber == 0) { logger.debug("Mapping column '" + column + "' to property '" + pd.getName() + "' of type " + pd.getPropertyType()); } try { bw.setPropertyValue(pd.getName(), value); } catch (TypeMismatchException e) { if (value == null && primitivesDefaultedForNullValue) { logger.debug("Intercepted TypeMismatchException for row " + rowNumber + " and column '" + column + "' with value " + value + " when setting property '" + pd.getName() + "' of type " + pd.getPropertyType() + " on object: " + mappedObject); } else { throw e; } } if (populatedProperties != null) { populatedProperties.add(pd.getName()); } } catch (NotWritablePropertyException ex) { throw new DataRetrievalFailureException( "Unable to map column " + column + " to property " + pd.getName(), ex); } } } if (populatedProperties != null && !populatedProperties.equals(this.mappedProperties)) { throw new InvalidDataAccessApiUsageException("Given ResultSet does not contain all fields " + "necessary to populate object of class [" + this.mappedClass + "]: " + this.mappedProperties); } return mappedObject; }
From source file:org.alfresco.repo.node.NodeServiceTest.java
/** * Check that simple node property modifications advance the node caches correctly *///from w ww . j av a2 s .c o m @SuppressWarnings("unchecked") @Test public void testCaches_ImmutableNodeCaches() throws Exception { final NodeRef[] nodeRefs = new NodeRef[2]; final NodeRef workspaceRootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); buildNodeHierarchy(workspaceRootNodeRef, nodeRefs); final NodeRef nodeRef = nodeRefs[1]; // Get the current node cache key Long nodeId = (Long) findCacheValue(nodesCache, nodeRef); assertNotNull("Node not found in cache", nodeId); Node nodeOne = (Node) findCacheValue(nodesCache, nodeId); assertNotNull("Node not found in cache", nodeOne); NodeVersionKey nodeKeyOne = nodeOne.getNodeVersionKey(); // Get the node cached values Map<QName, Serializable> nodePropsOne = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeyOne); Set<QName> nodeAspectsOne = (Set<QName>) findCacheValue(aspectsCache, nodeKeyOne); // Check the values assertEquals("The node version is incorrect", Long.valueOf(1L), nodeKeyOne.getVersion()); assertNotNull("No cache entry for properties", nodePropsOne); assertNotNull("No cache entry for aspects", nodeAspectsOne); assertEquals("Property count incorrect", 1, nodePropsOne.size()); assertNotNull("Expected a cm:name property", nodePropsOne.get(ContentModel.PROP_NAME)); assertEquals("Aspect count incorrect", 1, nodeAspectsOne.size()); assertTrue("Expected a cm:auditable aspect", nodeAspectsOne.contains(ContentModel.ASPECT_AUDITABLE)); // Add a property nodeService.setProperty(nodeRef, PROP_RESIDUAL, GUID.generate()); // Get the values for the previous version Map<QName, Serializable> nodePropsOneCheck = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeyOne); Set<QName> nodeAspectsOneCheck = (Set<QName>) findCacheValue(aspectsCache, nodeKeyOne); assertTrue("Previous cache entries must be left alone", nodePropsOneCheck.equals(nodePropsOne)); assertTrue("Previous cache entries must be left alone", nodeAspectsOneCheck.equals(nodeAspectsOne)); // Get the current node cache key Node nodeTwo = (Node) findCacheValue(nodesCache, nodeId); assertNotNull("Node not found in cache", nodeTwo); NodeVersionKey nodeKeyTwo = nodeTwo.getNodeVersionKey(); // Get the node cached values Map<QName, Serializable> nodePropsTwo = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeyTwo); Set<QName> nodeAspectsTwo = (Set<QName>) findCacheValue(aspectsCache, nodeKeyTwo); // Check the values assertEquals("The node version is incorrect", Long.valueOf(2L), nodeKeyTwo.getVersion()); assertNotNull("No cache entry for properties", nodePropsTwo); assertNotNull("No cache entry for aspects", nodeAspectsTwo); assertFalse("Properties must have moved on", nodePropsTwo.equals(nodePropsOne)); assertEquals("Property count incorrect", 2, nodePropsTwo.size()); assertNotNull("Expected a cm:name property", nodePropsTwo.get(ContentModel.PROP_NAME)); assertNotNull("Expected a residual property", nodePropsTwo.get(PROP_RESIDUAL)); assertTrue("Aspects must be carried", nodeAspectsTwo.equals(nodeAspectsOne)); // Remove a property nodeService.removeProperty(nodeRef, PROP_RESIDUAL); // Get the values for the previous version Map<QName, Serializable> nodePropsTwoCheck = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeyTwo); Set<QName> nodeAspectsTwoCheck = (Set<QName>) findCacheValue(aspectsCache, nodeKeyTwo); assertTrue("Previous cache entries must be left alone", nodePropsTwoCheck.equals(nodePropsTwo)); assertTrue("Previous cache entries must be left alone", nodeAspectsTwoCheck.equals(nodeAspectsTwo)); // Get the current node cache key Node nodeThree = (Node) findCacheValue(nodesCache, nodeId); assertNotNull("Node not found in cache", nodeThree); NodeVersionKey nodeKeyThree = nodeThree.getNodeVersionKey(); // Get the node cached values Map<QName, Serializable> nodePropsThree = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeyThree); Set<QName> nodeAspectsThree = (Set<QName>) findCacheValue(aspectsCache, nodeKeyThree); // Check the values assertEquals("The node version is incorrect", Long.valueOf(3L), nodeKeyThree.getVersion()); assertNotNull("No cache entry for properties", nodePropsThree); assertNotNull("No cache entry for aspects", nodeAspectsThree); assertFalse("Properties must have moved on", nodePropsThree.equals(nodePropsTwo)); assertEquals("Property count incorrect", 1, nodePropsThree.size()); assertNotNull("Expected a cm:name property", nodePropsThree.get(ContentModel.PROP_NAME)); assertNull("Expected no residual property", nodePropsThree.get(PROP_RESIDUAL)); assertTrue("Aspects must be carried", nodeAspectsThree.equals(nodeAspectsTwo)); // Add an aspect nodeService.addAspect(nodeRef, ContentModel.ASPECT_TITLED, null); // Get the values for the previous version Map<QName, Serializable> nodePropsThreeCheck = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeyThree); Set<QName> nodeAspectsThreeCheck = (Set<QName>) findCacheValue(aspectsCache, nodeKeyThree); assertTrue("Previous cache entries must be left alone", nodePropsThreeCheck.equals(nodePropsThree)); assertTrue("Previous cache entries must be left alone", nodeAspectsThreeCheck.equals(nodeAspectsThree)); // Get the current node cache key Node nodeFour = (Node) findCacheValue(nodesCache, nodeId); assertNotNull("Node not found in cache", nodeFour); NodeVersionKey nodeKeyFour = nodeFour.getNodeVersionKey(); // Get the node cached values Map<QName, Serializable> nodePropsFour = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeyFour); Set<QName> nodeAspectsFour = (Set<QName>) findCacheValue(aspectsCache, nodeKeyFour); // Check the values assertEquals("The node version is incorrect", Long.valueOf(4L), nodeKeyFour.getVersion()); assertNotNull("No cache entry for properties", nodePropsFour); assertNotNull("No cache entry for aspects", nodeAspectsFour); assertTrue("Properties must be carried", nodePropsFour.equals(nodePropsThree)); assertFalse("Aspects must have moved on", nodeAspectsFour.equals(nodeAspectsThree)); assertTrue("Expected cm:titled aspect", nodeAspectsFour.contains(ContentModel.ASPECT_TITLED)); // Remove an aspect nodeService.removeAspect(nodeRef, ContentModel.ASPECT_TITLED); // Get the values for the previous version Map<QName, Serializable> nodePropsFourCheck = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeyFour); Set<QName> nodeAspectsFourCheck = (Set<QName>) findCacheValue(aspectsCache, nodeKeyFour); assertTrue("Previous cache entries must be left alone", nodePropsFourCheck.equals(nodePropsFour)); assertTrue("Previous cache entries must be left alone", nodeAspectsFourCheck.equals(nodeAspectsFour)); // Get the current node cache key Node nodeFive = (Node) findCacheValue(nodesCache, nodeId); assertNotNull("Node not found in cache", nodeFive); NodeVersionKey nodeKeyFive = nodeFive.getNodeVersionKey(); // Get the node cached values Map<QName, Serializable> nodePropsFive = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeyFive); Set<QName> nodeAspectsFive = (Set<QName>) findCacheValue(aspectsCache, nodeKeyFive); // Check the values assertEquals("The node version is incorrect", Long.valueOf(5L), nodeKeyFive.getVersion()); assertNotNull("No cache entry for properties", nodePropsFive); assertNotNull("No cache entry for aspects", nodeAspectsFive); assertTrue("Properties must be carried", nodePropsFive.equals(nodePropsFour)); assertFalse("Aspects must have moved on", nodeAspectsFive.equals(nodeAspectsFour)); assertFalse("Expected no cm:titled aspect ", nodeAspectsFive.contains(ContentModel.ASPECT_TITLED)); // Add an aspect, some properties and secondary association RetryingTransactionCallback<Void> nodeSixWork = new RetryingTransactionCallback<Void>() { @Override public Void execute() throws Throwable { Map<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(ContentModel.PROP_TITLE, "some title"); nodeService.addAspect(nodeRef, ContentModel.ASPECT_TITLED, props); nodeService.setProperty(nodeRef, ContentModel.PROP_DESCRIPTION, "Some description"); // Adding a child node now triggers behaviour to update a CRC property // nodeService.addChild( // Collections.singletonList(workspaceRootNodeRef), // nodeRef, // ContentModel.ASSOC_CHILDREN, // QName.createQName(TEST_PREFIX, "secondary")); return null; } }; txnService.getRetryingTransactionHelper().doInTransaction(nodeSixWork); // Get the values for the previous version Map<QName, Serializable> nodePropsFiveCheck = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeyFive); Set<QName> nodeAspectsFiveCheck = (Set<QName>) findCacheValue(aspectsCache, nodeKeyFive); assertTrue("Previous cache entries must be left alone", nodePropsFiveCheck.equals(nodePropsFive)); assertTrue("Previous cache entries must be left alone", nodeAspectsFiveCheck.equals(nodeAspectsFive)); // Get the current node cache key Node nodeSix = (Node) findCacheValue(nodesCache, nodeId); assertNotNull("Node not found in cache", nodeSix); NodeVersionKey nodeKeySix = nodeSix.getNodeVersionKey(); // Get the node cached values Map<QName, Serializable> nodePropsSix = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeySix); Set<QName> nodeAspectsSix = (Set<QName>) findCacheValue(aspectsCache, nodeKeySix); // Check the values assertEquals("The node version is incorrect", Long.valueOf(6L), nodeKeySix.getVersion()); assertNotNull("No cache entry for properties", nodePropsSix); assertNotNull("No cache entry for aspects", nodeAspectsSix); assertFalse("Properties must have moved on", nodePropsSix.equals(nodePropsFive)); assertEquals("Property count incorrect", 3, nodePropsSix.size()); assertNotNull("Expected a cm:name property", nodePropsSix.get(ContentModel.PROP_NAME)); assertNotNull("Expected a cm:title property", nodePropsSix.get(ContentModel.PROP_TITLE)); assertNotNull("Expected a cm:description property", nodePropsSix.get(ContentModel.PROP_DESCRIPTION)); assertFalse("Aspects must have moved on", nodeAspectsSix.equals(nodeAspectsFive)); assertTrue("Expected cm:titled aspect ", nodeAspectsSix.contains(ContentModel.ASPECT_TITLED)); // Remove an aspect, some properties and a secondary association RetryingTransactionCallback<Void> nodeSevenWork = new RetryingTransactionCallback<Void>() { @Override public Void execute() throws Throwable { nodeService.removeAspect(nodeRef, ContentModel.ASPECT_TITLED); nodeService.removeChild(workspaceRootNodeRef, nodeRef); return null; } }; txnService.getRetryingTransactionHelper().doInTransaction(nodeSevenWork); // Get the values for the previous version Map<QName, Serializable> nodePropsSixCheck = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeySix); Set<QName> nodeAspectsSixCheck = (Set<QName>) findCacheValue(aspectsCache, nodeKeySix); assertTrue("Previous cache entries must be left alone", nodePropsSixCheck.equals(nodePropsSix)); assertTrue("Previous cache entries must be left alone", nodeAspectsSixCheck.equals(nodeAspectsSix)); // Get the current node cache key Node nodeSeven = (Node) findCacheValue(nodesCache, nodeId); assertNotNull("Node not found in cache", nodeSeven); NodeVersionKey nodeKeySeven = nodeSeven.getNodeVersionKey(); // Get the node cached values Map<QName, Serializable> nodePropsSeven = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeySeven); Set<QName> nodeAspectsSeven = (Set<QName>) findCacheValue(aspectsCache, nodeKeySeven); // Check the values assertEquals("The node version is incorrect", Long.valueOf(7L), nodeKeySeven.getVersion()); assertNotNull("No cache entry for properties", nodePropsSeven); assertNotNull("No cache entry for aspects", nodeAspectsSeven); assertFalse("Properties must have moved on", nodePropsSeven.equals(nodePropsSix)); assertEquals("Property count incorrect", 1, nodePropsSeven.size()); assertNotNull("Expected a cm:name property", nodePropsSeven.get(ContentModel.PROP_NAME)); assertFalse("Aspects must have moved on", nodeAspectsSeven.equals(nodeAspectsSix)); assertFalse("Expected no cm:titled aspect ", nodeAspectsSeven.contains(ContentModel.ASPECT_TITLED)); // Modify cm:auditable RetryingTransactionCallback<Void> nodeEightWork = new RetryingTransactionCallback<Void>() { @Override public Void execute() throws Throwable { BehaviourFilter behaviourFilter = (BehaviourFilter) APP_CONTEXT_INIT.getApplicationContext() .getBean("policyBehaviourFilter"); // Disable behaviour for txn behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE); nodeService.setProperty(nodeRef, ContentModel.PROP_MODIFIER, "Fred"); return null; } }; txnService.getRetryingTransactionHelper().doInTransaction(nodeEightWork); // Get the values for the previous version Map<QName, Serializable> nodePropsSevenCheck = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeySeven); Set<QName> nodeAspectsSevenCheck = (Set<QName>) findCacheValue(aspectsCache, nodeKeySeven); assertTrue("Previous cache entries must be left alone", nodePropsSevenCheck.equals(nodePropsSeven)); assertTrue("Previous cache entries must be left alone", nodeAspectsSevenCheck.equals(nodeAspectsSeven)); // Get the current node cache key Node nodeEight = (Node) findCacheValue(nodesCache, nodeId); assertNotNull("Node not found in cache", nodeEight); NodeVersionKey nodeKeyEight = nodeEight.getNodeVersionKey(); // Get the node cached values Map<QName, Serializable> nodePropsEight = (Map<QName, Serializable>) findCacheValue(propsCache, nodeKeyEight); Set<QName> nodeAspectsEight = (Set<QName>) findCacheValue(aspectsCache, nodeKeyEight); // Check the values assertEquals("The node version is incorrect", Long.valueOf(8L), nodeKeyEight.getVersion()); assertNotNull("No cache entry for properties", nodePropsEight); assertNotNull("No cache entry for aspects", nodeAspectsEight); assertEquals("Expected change to cm:modifier", "Fred", nodeEight.getAuditableProperties().getAuditModifier()); assertTrue("Properties must be carried", nodePropsEight.equals(nodePropsSeven)); assertTrue("Aspects be carried", nodeAspectsEight.equals(nodeAspectsSeven)); }
From source file:org.voltdb.iv2.LeaderAppointer.java
private void doPartitionDetectionActivities(Set<Integer> currentNodes) { // We should never re-enter here once we've decided we're partitioned and doomed assert (!m_partitionDetected); Set<Integer> currentHosts = new HashSet<Integer>(currentNodes); Set<Integer> previousHosts = readPriorKnownLiveNodes(); boolean partitionDetectionTriggered = makePPDDecision(previousHosts, currentHosts); if (partitionDetectionTriggered) { m_partitionDetected = true;/*from www . j a v a2 s . c o m*/ if (m_usingCommandLog) { // Just shut down immediately VoltDB.crashGlobalVoltDB("Use of command logging detected, no additional database snapshot will " + "be generated. Please use the 'recover' action to restore the database if necessary.", false, null); } else { SnapshotUtil.requestSnapshot(0L, m_partSnapshotSchedule.getPath(), m_partSnapshotSchedule.getPrefix() + System.currentTimeMillis(), true, SnapshotFormat.NATIVE, null, m_snapshotHandler, true); } } // If the cluster host set has changed, then write the new set to ZK // NOTE: we don't want to update the known live nodes if we've decided that our subcluster is // dying, otherwise a poorly timed subsequent failure might reverse this decision. Any future promoted // LeaderAppointer should make their partition detection decision based on the pre-partition cluster state. else if (!currentHosts.equals(previousHosts)) { writeKnownLiveNodes(currentNodes); } }
From source file:org.openconcerto.sql.model.SQLTable.java
private synchronized String equalsChildren(SQLTable o, SQLSystem otherSystem) { if (!this.getChildrenNames().equals(o.getChildrenNames())) return "fields differences: " + this.getChildrenNames() + "\n" + o.getChildrenNames(); final String noLink = equalsChildrenNoLink(o, otherSystem); if (noLink != null) return noLink; // foreign keys final Set<Link> thisLinks = this.getDBSystemRoot().getGraph().getForeignLinks(this); final Set<Link> oLinks = o.getDBSystemRoot().getGraph().getForeignLinks(o); if (thisLinks.size() != oLinks.size()) return "different number of foreign keys " + thisLinks + " != " + oLinks; for (final Link l : thisLinks) { final Link ol = o.getDBSystemRoot().getGraph().getForeignLink(o, l.getCols()); if (ol == null) return "no foreign key for " + l.getLabel(); final SQLName thisPath = l.getTarget().getContextualSQLName(this); final SQLName oPath = ol.getTarget().getContextualSQLName(o); if (thisPath.getItemCount() != oPath.getItemCount()) return "unequal path size : " + thisPath + " != " + oPath; if (!thisPath.getName().equals(oPath.getName())) return "unequal referenced table name : " + thisPath.getName() + " != " + oPath.getName(); final SQLSystem thisSystem = this.getServer().getSQLSystem(); if (!getRule(l.getUpdateRule(), thisSystem, otherSystem) .equals(getRule(ol.getUpdateRule(), thisSystem, otherSystem))) return "unequal update rule for " + l + ": " + l.getUpdateRule() + " != " + ol.getUpdateRule(); if (!getRule(l.getDeleteRule(), thisSystem, otherSystem) .equals(getRule(ol.getDeleteRule(), thisSystem, otherSystem))) return "unequal delete rule for " + l + ": " + l.getDeleteRule() + " != " + ol.getDeleteRule(); }//from w w w .ja v a2s .co m final Set<Constraint> thisConstraints; final Set<Constraint> otherConstraints; try { final Tuple2<Set<Constraint>, Set<Index>> thisConstraintsAndIndexes = this.getConstraintsAndIndexes(); final Tuple2<Set<Constraint>, Set<Index>> otherConstraintsAndIndexes = o.getConstraintsAndIndexes(); // order irrelevant final Set<Index> thisIndexesSet = thisConstraintsAndIndexes.get1(); final Set<Index> oIndexesSet = otherConstraintsAndIndexes.get1(); if (!thisIndexesSet.equals(oIndexesSet)) return "indexes differences: " + thisIndexesSet + "\n" + oIndexesSet; thisConstraints = thisConstraintsAndIndexes.get0(); otherConstraints = otherConstraintsAndIndexes.get0(); } catch (SQLException e) { // MAYBE fetch indexes with the rest to avoid exn now return "couldn't get indexes: " + ExceptionUtils.getStackTrace(e); } if (!CompareUtils.equals(thisConstraints, otherConstraints)) return "constraints unequal : '" + thisConstraints + "' != '" + otherConstraints + "'"; return null; }
From source file:org.openmicroscopy.shoola.agents.treeviewer.browser.BrowserComponent.java
/** * Implemented as specified by the {@link Browser} interface. * @see Browser#removeTreeNodes(Collection) *///from w w w. ja v a 2s . c o m public void removeTreeNodes(Collection<TreeImageDisplay> nodes) { if (nodes == null) return; Iterator<TreeImageDisplay> i = nodes.iterator(); TreeImageDisplay node; TreeImageDisplay parent; while (i.hasNext()) { node = i.next(); parent = node.getParentDisplay(); if (parent != null) { parent.removeChildDisplay(node); node.removeFromParent(); view.reloadNode(parent); } } /* ensure that the selected displays do not include any removed nodes */ final Set<TreeImageDisplay> oldSelected = Sets.newHashSet(getSelectedDisplays()); final Set<TreeImageDisplay> newSelected = Sets.newHashSet(oldSelected); newSelected.removeAll(nodes); if (!newSelected.equals(oldSelected)) { setSelectedDisplay(null); setSelectedDisplays(newSelected.toArray(new TreeImageDisplay[newSelected.size()]), false); } }
From source file:ru.codeinside.adm.AdminServiceImpl.java
private void setUserGroups(final Employee e, Set<String> names) { final Set<String> oldNames = new HashSet<String>(); final Set<Group> deletions = new HashSet<Group>(); for (final Group group : e.getGroups()) { final String name = group.getName(); oldNames.add(name);// ww w .j av a 2 s . c o m if (!names.contains(name)) { deletions.add(group); } } // ?! if (!oldNames.equals(names)) { for (final Group group : deletions) { group.getEmployees().remove(e); e.getGroups().remove(group); } final Set<String> addNames = new HashSet<String>(names); addNames.removeAll(oldNames); for (final String name : addNames) { final Group group = getOrCreateGroupByName(name, true); group.getEmployees().add(e); e.getGroups().add(group); } final Set<Group> deletions2 = new HashSet<Group>(deletions); deletions2.removeAll(e.getOrganization().getGroups()); syncUser(e, deletions2, addNames, processEngine.get().getIdentityService()); } }
From source file:ru.codeinside.adm.AdminServiceImpl.java
@Override public boolean setOrgGroupNames(final long orgId, final Set<String> names) { final Set<String> oldNames = new HashSet<String>(); final Organization org = em.getReference(Organization.class, orgId); final Set<Group> deletions = new HashSet<Group>(); for (final Group group : org.getGroups()) { final String name = group.getName(); oldNames.add(name);//w ww . j a v a 2 s . c o m if (!names.contains(name)) { deletions.add(group); } } if (!oldNames.equals(names)) { for (final Group group : deletions) { group.getOrganizations().remove(org); org.getGroups().remove(group); } final Set<String> addNames = new HashSet<String>(names); addNames.removeAll(oldNames); for (final String name : addNames) { final Group group = getOrCreateGroupByName(name, false); group.getOrganizations().add(org); org.getGroups().add(group); } final IdentityService act = processEngine.get().getIdentityService(); for (final Employee employee : org.getEmployees()) { final Set<Group> deletions2 = new HashSet<Group>(deletions); deletions2.removeAll(employee.getGroups()); syncUser(employee, deletions2, addNames, act); } } return !oldNames.equals(names); }
From source file:edu.umass.cs.reconfiguration.Reconfigurator.java
private Set<NodeIDType> shouldReconfigure(String name) { // return null if no current actives Set<NodeIDType> oldActives = this.DB.getActiveReplicas(name); if (oldActives == null || oldActives.isEmpty()) return null; // get new IP addresses (via consistent hashing if no oldActives ArrayList<InetAddress> newActiveIPs = this.demandProfiler.testAndSetReconfigured(name, this.consistentNodeConfig.getNodeIPs(oldActives)); if (newActiveIPs == null) return null; // get new actives based on new IP addresses Set<NodeIDType> newActives = this.consistentNodeConfig.getIPToActiveReplicaIDs(newActiveIPs, oldActives); return (!newActives.equals(oldActives) || ReconfigurationConfig.shouldReconfigureInPlace()) ? newActives : null;//from ww w.ja va 2 s . co m }
From source file:com.wantscart.jade.core.BeanPropertyRowMapper.java
/** * Extract the values for all columns in the current row. * <p/>// w w w . j a v a2 s.com * Utilizes public setters and result set metadata. * * @see java.sql.ResultSetMetaData */ public Object mapRow(ResultSet rs, int rowNumber) throws SQLException { // spring's : Object mappedObject = BeanUtils.instantiateClass(this.mappedClass); // jade's : private Object instantiateClass(this.mappedClass); // why: ??mappedClass.newInstranceBeanUtils.instantiateClass(mappedClass)1? Object mappedObject = instantiateClass(this.mappedClass); BeanWrapper bw = new BeanWrapperImpl(mappedObject); ResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount(); boolean warnEnabled = logger.isWarnEnabled(); boolean debugEnabled = logger.isDebugEnabled(); Set<String> populatedProperties = (checkProperties ? new HashSet<String>() : null); for (int index = 1; index <= columnCount; index++) { String columnName = JdbcUtils.lookupColumnName(rsmd, index).toLowerCase(); TableSchema.Column col = this.mappedFields.get(columnName); if (col != null) { try { Object value = JdbcUtils.getResultSetValue(rs, index, (Class<?>) col.getColumnType()); if (debugEnabled && rowNumber == 0) { logger.debug("Mapping column '" + columnName + "' to property '" + col.getName() + "' of type " + col.getType()); } if (col.isSerializable()) { if (col.getSerializer().getClass() != NullSerializer.class) { value = col.getSerializer().deserialize(value, col.getGenericType() != null ? col.getGenericType() : col.getType()); } else { Serializable instance = (Serializable) BeanUtils .instantiateClass((Class) col.getType()); instance.deserialize(value); value = instance; } } bw.setPropertyValue(col.getOriginName(), value); if (populatedProperties != null) { populatedProperties.add(col.getName()); } } catch (NotWritablePropertyException ex) { throw new DataRetrievalFailureException( "Unable to map column " + columnName + " to property " + col.getOriginName(), ex); } } else { if (checkColumns) { throw new InvalidDataAccessApiUsageException("Unable to map column '" + columnName + "' to any properties of bean " + this.mappedClass.getName()); } if (warnEnabled && rowNumber == 0) { logger.warn("Unable to map column '" + columnName + "' to any properties of bean " + this.mappedClass.getName()); } } } if (populatedProperties != null && !populatedProperties.equals(this.mappedProperties)) { throw new InvalidDataAccessApiUsageException("Given ResultSet does not contain all fields " + "necessary to populate object of class [" + this.mappedClass + "]: " + this.mappedProperties); } return mappedObject; }