/** * Finds an interaction based on its properties. * * @param interaction the object we are searching an AC for. * @return an AC or null if it couldn't be found. */ protected String findAcForInteraction( Interaction interaction ) { CrcCalculator crcCalculator = new CrcCalculator(); String interactionCrc = crcCalculator.crc64( interaction ); Query query = getEntityManager().createQuery("select i.ac from InteractionImpl i where i.crc = :crc"); query.setParameter("crc", interactionCrc); Set<String> acs = new HashSet<String>(query.getResultList()); if (acs.isEmpty()) { return null; } if (acs.size() > 1) { log.error("More than one interaction found using the CRC ("+interactionCrc+"). Returning the first one"); } return acs.iterator().next(); }
/** * Finds an interaction based on its properties. * * @param interaction the object we are searching an AC for. * @return an AC or null if it couldn't be found. */ protected String findAcForInteraction( Interaction interaction ) { CrcCalculator crcCalculator = new CrcCalculator(); String interactionCrc = crcCalculator.crc64( interaction ); Query query = getEntityManager().createQuery("select i.ac from InteractionImpl i where i.crc = :crc"); query.setParameter("crc", interactionCrc); Set<String> acs = new HashSet<String>(query.getResultList()); if (acs.isEmpty()) { return null; } if (acs.size() > 1) { log.error("More than one interaction found using the CRC ("+interactionCrc+"). Returning the first one"); } return acs.iterator().next(); }
public void calculateCrc() { CrcCalculator crcCalculator = new CrcCalculator(); Instant before = new Instant(); String newCrc = crcCalculator.crc64(this); if (crc == null){ crc = newCrc; } else if (!crc.equals(newCrc)){ crc = newCrc; } Instant after = new Instant(); if (log.isDebugEnabled()) log.debug("Calculated crc for interaction '" + getShortLabel() + "' in " + new Duration(before, after).getMillis() + "ms: " + crc); }
public void calculateCrc() { CrcCalculator crcCalculator = new CrcCalculator(); Instant before = new Instant(); String newCrc = crcCalculator.crc64(this); if (crc == null){ crc = newCrc; } else if (!crc.equals(newCrc)){ crc = newCrc; } Instant after = new Instant(); if (log.isDebugEnabled()) log.debug("Calculated crc for interaction '" + getShortLabel() + "' in " + new Duration(before, after).getMillis() + "ms: " + crc); }
@Override protected String findAcForInteraction( Interaction interaction ) { // replace all this eventually by just using the CRC InteractionDao interactionDao = getDaoFactory().getInteractionDao(); CrcCalculator crcCalculator = new CrcCalculator(); // Get the interactors where exactly the same interactors are involved List<String> interactorPrimaryIDs = InteractionUtils.getInteractorPrimaryIDs( interaction ); List<Interaction> interactionsWithSameInteractors = interactionDao.getByInteractorsPrimaryId( true, interactorPrimaryIDs.toArray( new String[interactorPrimaryIDs.size()] ) ); for ( Interaction interactionWithSameInteractor : interactionsWithSameInteractors ) { String interactionCrc = crcCalculator.crc64( interaction ); String interactionWithSameInteractorCrc = crcCalculator.crc64( interactionWithSameInteractor ); if ( interactionCrc.equals( interactionWithSameInteractorCrc ) ) { return interactionWithSameInteractor.getAc(); } } return null; }
@Override protected String findAcForInteraction( Interaction interaction ) { // replace all this eventually by just using the CRC InteractionDao interactionDao = getDaoFactory().getInteractionDao(); CrcCalculator crcCalculator = new CrcCalculator(); // Get the interactors where exactly the same interactors are involved List<String> interactorPrimaryIDs = InteractionUtils.getInteractorPrimaryIDs( interaction ); List<Interaction> interactionsWithSameInteractors = interactionDao.getByInteractorsPrimaryId( true, interactorPrimaryIDs.toArray( new String[interactorPrimaryIDs.size()] ) ); for ( Interaction interactionWithSameInteractor : interactionsWithSameInteractors ) { String interactionCrc = crcCalculator.crc64( interaction ); String interactionWithSameInteractorCrc = crcCalculator.crc64( interactionWithSameInteractor ); if ( interactionCrc.equals( interactionWithSameInteractorCrc ) ) { return interactionWithSameInteractor.getAc(); } } return null; }
protected Key keyForInteraction(Interaction interaction) { final Key key = new Key(new CrcCalculator().crc64(interaction)); // pre-calculate the keys for the components here and put them in a map int n = 0; for (Component component : interaction.getComponents()) { Key compKey = new Key(key.getUniqueString() + ":" + component.getShortLabel() + "[" + n + "]"); keyCache.put(Component.class.getSimpleName() + ":" + System.identityHashCode(component), compKey); n++; } return key; }
protected Key keyForInteraction(Interaction interaction) { final Key key = new Key(new CrcCalculator().crc64(interaction)); // pre-calculate the keys for the components here and put them in a map int n = 0; for (Component component : interaction.getComponents()) { Key compKey = new Key(key.getUniqueString() + ":" + component.getShortLabel() + "[" + n + "]"); keyCache.put(Component.class.getSimpleName() + ":" + System.identityHashCode(component), compKey); n++; } return key; }