Example usage for java.lang Long equals

List of usage examples for java.lang Long equals

Introduction

In this page you can find the example usage for java.lang Long equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:com.redhat.rhn.domain.server.test.ServerFactoryTest.java

public void testGetServerHistory() throws Exception {

    Server serverTest = ServerFactoryTest.createTestServer(user);
    ServerHistoryEvent event1 = new ServerHistoryEvent();
    event1.setSummary("summary1");
    event1.setDetails("details1");
    event1.setServer(serverTest);//from  w  ww  . j a  v  a2 s  . c  om

    Set history = serverTest.getHistory();
    history.add(event1);

    ServerFactory.save(serverTest);
    TestUtils.saveAndFlush(event1);
    Long eventId = event1.getId();
    Long sid = serverTest.getId();

    HibernateFactory.getSession().clear();
    serverTest = ServerFactory.lookupById(sid);
    boolean hasEvent = false;
    for (ServerHistoryEvent she : serverTest.getHistory()) {
        if (eventId.equals(she.getId())) {
            hasEvent = true;
            break;
        }
    }
    assertTrue(hasEvent);
}

From source file:com.square.core.service.implementations.OpportuniteServiceImplementation.java

/**
 * Teste si une liste d'adresses a une adresse principale.
 * @param listeAdresses la liste d'adresses
 * @return true si la liste possde une adresse principale, false sinon
 *///ww w .  ja  v  a  2  s.  com
private boolean possedeAdressePrincipale(List<Adresse> listeAdresses) {
    final Long idNatureAdressePrincipale = squareMappingService.getIdNatureAdressePrincipale();
    for (Adresse adresse : listeAdresses) {
        final Long idNatureAdresse = adresse.getNature().getId();
        if (idNatureAdressePrincipale.equals(idNatureAdresse) && adresse.getCodePostalCommune() != null
                && adresse.getCodePostalCommune().getId() != null) {
            return true;
        }
    }
    return false;
}

From source file:jp.primecloud.auto.service.impl.IaasDescribeServiceImpl.java

/**
 * {@inheritDoc}// www  . jav a 2  s  . c  o  m
 */
@Override
public List<AddressDto> getAddresses(Long userNo, Long platformNo) {
    // ?
    if (userNo == null) {
        throw new AutoApplicationException("ECOMMON-000003", "userNo");
    }
    if (platformNo == null) {
        throw new AutoApplicationException("ECOMMON-000003", "platformNo");
    }

    Platform platform = platformDao.read(platformNo);

    List<AddressDto> addresses = new ArrayList<AddressDto>();
    // TODO CLOUD BRANCHING
    if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) {
        // ?????AWS?
        List<AwsAddress> allAddresses = awsAddressDao.readByUserNo(userNo);
        for (AwsAddress address : allAddresses) {
            if (platformNo.equals(address.getPlatformNo())) {
                addresses.add(new AddressDto(address));
            }
        }
    } else if (PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(platform.getPlatformType())) {
        // ?????Cloudstack?
        List<CloudstackAddress> allAddresses = cloudstackAddressDao.readByAccount(userNo);
        for (CloudstackAddress address : allAddresses) {
            if (platformNo.equals(address.getPlatformNo())) {
                addresses.add(new AddressDto(address));
            }
        }

    }
    return addresses;
}

From source file:jp.primecloud.auto.service.impl.ProcessServiceImpl.java

/**
 * {@inheritDoc}/*from   www.  jav a  2 s.  c o  m*/
 */
@Override
public boolean checkStartup(String platformType, String instanceName, Long instanceNo) {
    if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platformType)) {
        // ?????????
        if (StringUtils.isEmpty(instanceName)) {
            List<AzureInstance> azureInstances = azureInstanceDao.readAll();
            // Azure??????????
            for (AzureInstance azureInstance : azureInstances) {
                Instance instance = instanceDao.read(azureInstance.getInstanceNo());
                if (instanceNo.equals(instance.getInstanceNo()) == false
                        && (instance.getStatus().equals(InstanceStatus.STARTING.toString())
                                || instance.getStatus().equals(InstanceStatus.CONFIGURING.toString()))
                        && StringUtils.isEmpty(azureInstance.getInstanceName())) {
                    // ????????????
                    // ?No???
                    return true;
                }
            }
        }
    }
    return false;
}

From source file:com.att.aro.ui.view.diagnostictab.plot.BufferInSecondsPlot.java

@Override
public void populate(XYPlot plot, AROTraceData analysis) {
    if (analysis != null) {
        VideoUsage videoUsage = analysis.getAnalyzerResult().getVideoUsage();
        bufferFillDataCollection.removeAllSeries();
        seriesBufferFill = new XYSeries("Buffer Against Play Time");
        seriesDataSets = new TreeMap<>();

        seriesDataSets = bufferInSecondsCalculatorImpl.populate(videoUsage, chunkPlayTimeList);
        //updating video stall result in packetAnalyzerResult
        analysis.getAnalyzerResult().setVideoStalls(bufferInSecondsCalculatorImpl.getVideoStallResult());

        bufferTimeList.clear();/*from ww w .j  a v  a2 s .  c o m*/
        double xCoordinate, yCoordinate;
        String ptCoordinate[] = new String[2]; // to hold x & y values
        if (!seriesDataSets.isEmpty()) {

            for (int key : seriesDataSets.keySet()) {
                ptCoordinate = seriesDataSets.get(key).trim().split(",");
                xCoordinate = Double.parseDouble(ptCoordinate[0]);
                yCoordinate = Double.parseDouble(ptCoordinate[1]);
                bufferTimeList.add(yCoordinate);

                seriesBufferFill.add(xCoordinate, yCoordinate);
            }
        }

        Collections.sort(bufferTimeList);
        BufferTimeBPResult bufferTimeResult = bufferInSecondsCalculatorImpl
                .updateBufferTimeResult(bufferTimeList);
        analysis.getAnalyzerResult().setBufferTimeResult(bufferTimeResult);
        // populate collection
        bufferFillDataCollection.addSeries(seriesBufferFill);

        XYItemRenderer renderer = new StandardXYItemRenderer();
        renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {

                // Tooltip value
                Number timestamp = dataset.getX(series, item);
                Number bufferTime = dataset.getY(series, item);
                StringBuffer tooltipValue = new StringBuffer();

                Map<Double, Long> segmentEndTimeMap = bufferInSecondsCalculatorImpl.getSegmentEndTimeMap();
                Map<Long, Double> segmentStartTimeMap = bufferInSecondsCalculatorImpl.getSegmentStartTimeMap();
                double firstSegmentNo = videoUsage.getChunksBySegmentNumber().get(0).getSegment();

                DecimalFormat decimalFormat = new DecimalFormat("0.##");
                if (segmentStartTimeMap == null || segmentStartTimeMap.isEmpty()) {
                    return "-,-,-";
                }

                List<Long> segmentList = new ArrayList<Long>(segmentEndTimeMap.values());
                Collections.sort(segmentList);
                Long lastSegmentNo = segmentList.get(segmentList.size() - 1);

                Long segmentNumber = 0L;
                boolean isSegmentPlaying = false;
                boolean startup = false;
                boolean endPlay = false;

                for (double segmentEndTime : segmentEndTimeMap.keySet()) {
                    if (segmentEndTime > timestamp.doubleValue()) {
                        segmentNumber = segmentEndTimeMap.get(segmentEndTime);
                        if (segmentNumber == firstSegmentNo) {
                            startup = true;
                        }
                        if (segmentStartTimeMap.get(segmentNumber) <= timestamp.doubleValue()) {
                            tooltipValue.append(decimalFormat.format(segmentNumber) + ",");
                            isSegmentPlaying = true;
                            startup = false;
                        }
                    } else if (lastSegmentNo.equals(segmentEndTimeMap.get(segmentEndTime))
                            && segmentEndTime == timestamp.doubleValue()) {
                        endPlay = true;
                    }
                }

                if (endPlay || startup) {
                    tooltipValue.append("-,");
                } else if (!isSegmentPlaying && !startup) {
                    tooltipValue.append("Stall,");
                }

                tooltipValue.append(String.format("%.2f", bufferTime) + "," + String.format("%.2f", timestamp));

                String[] value = tooltipValue.toString().split(",");
                return (MessageFormat.format(BUFFER_TIME_OCCUPANCY_TOOLTIP, value[0], value[1], value[2]));
            }

        });
        renderer.setSeriesStroke(0, new BasicStroke(2.0f));
        renderer.setSeriesPaint(0, Color.MAGENTA);

        renderer.setSeriesShape(0, shape);

        plot.setRenderer(renderer);

    }
    plot.setDataset(bufferFillDataCollection);
}

From source file:org.kuali.mobility.maps.service.LocationServiceImpl.java

@Transactional
public void addMapsGroupToLocation(Long groupId, Long locationId) {
    Location location = this.getLocationById(locationId);
    Set<MapsGroup> mapsGroups = null;
    boolean addGroup = true;
    if (location.getMapsGroups().size() == 0) {
        location.setMapsGroups(new HashSet<MapsGroup>());
    } else {// ww w .  j  av  a 2  s  . c  o  m
        mapsGroups = location.getMapsGroups();
        for (MapsGroup mapsGroup : mapsGroups) {
            if (groupId.equals(mapsGroup.getGroupId())) {
                addGroup = false;
            }
        }
    }
    if (addGroup) {
        MapsGroup mapsGroupAdd = this.getMapsGroupByIdLazy(groupId);
        if (mapsGroupAdd != null) {
            location.getMapsGroups().add(mapsGroupAdd);
            this.saveLocation(location);
        }
    }
}

From source file:org.alfresco.repo.domain.node.NodePropertyHelper.java

public Map<QName, Serializable> convertToPublicProperties(
        Map<NodePropertyKey, NodePropertyValue> propertyValues) {
    Map<QName, Serializable> propertyMap = new HashMap<QName, Serializable>(propertyValues.size(), 1.0F);
    // Shortcut/*from w w  w  .  ja  v  a  2s . c  o  m*/
    if (propertyValues.size() == 0) {
        return propertyMap;
    }
    // We need to process the properties in order
    SortedMap<NodePropertyKey, NodePropertyValue> sortedPropertyValues = new TreeMap<NodePropertyKey, NodePropertyValue>(
            propertyValues);
    // A working map. Ordering is important.
    SortedMap<NodePropertyKey, NodePropertyValue> scratch = new TreeMap<NodePropertyKey, NodePropertyValue>();
    // Iterate (sorted) over the map entries and extract values with the same qname
    Long currentQNameId = Long.MIN_VALUE;
    Iterator<Map.Entry<NodePropertyKey, NodePropertyValue>> iterator = sortedPropertyValues.entrySet()
            .iterator();
    while (true) {
        Long nextQNameId = null;
        NodePropertyKey nextPropertyKey = null;
        NodePropertyValue nextPropertyValue = null;
        // Record the next entry's values
        if (iterator.hasNext()) {
            Map.Entry<NodePropertyKey, NodePropertyValue> entry = iterator.next();
            nextPropertyKey = entry.getKey();
            nextPropertyValue = entry.getValue();
            nextQNameId = nextPropertyKey.getQnameId();
        }
        // If the QName is going to change, and we have some entries to process, then process them.
        if (scratch.size() > 0 && (nextQNameId == null || !nextQNameId.equals(currentQNameId))) {
            QName currentQName = qnameDAO.getQName(currentQNameId).getSecond();
            PropertyDefinition currentPropertyDef = dictionaryService.getProperty(currentQName);
            // We have added something to the scratch properties but the qname has just changed
            Serializable collapsedValue = null;
            // We can shortcut if there is only one value
            if (scratch.size() == 1) {
                // There is no need to collapse list indexes
                collapsedValue = collapsePropertiesWithSameQNameAndListIndex(currentPropertyDef, scratch);
            } else {
                // There is more than one value so the list indexes need to be collapsed
                collapsedValue = collapsePropertiesWithSameQName(currentPropertyDef, scratch);
            }
            boolean forceCollection = false;
            // If the property is multi-valued then the output property must be a collection
            if (currentPropertyDef != null && currentPropertyDef.isMultiValued()) {
                forceCollection = true;
            } else if (scratch.size() == 1 && scratch.firstKey().getListIndex().intValue() > -1) {
                // This is to handle cases of collections where the property is d:any but not
                // declared as multiple.
                forceCollection = true;
            }
            if (forceCollection && collapsedValue != null && !(collapsedValue instanceof Collection<?>)) {
                // Can't use Collections.singletonList: ETHREEOH-1172
                ArrayList<Serializable> collection = new ArrayList<Serializable>(1);
                collection.add(collapsedValue);
                collapsedValue = collection;
            }

            // Store the value
            propertyMap.put(currentQName, collapsedValue);
            // Reset
            scratch.clear();
        }
        if (nextQNameId != null) {
            // Add to the current entries
            scratch.put(nextPropertyKey, nextPropertyValue);
            currentQNameId = nextQNameId;
        } else {
            // There is no next value to process
            break;
        }
    }
    // Done
    return propertyMap;
}

From source file:com.alibaba.otter.shared.arbitrate.impl.setl.monitor.MainstemMonitor.java

public void initMainstem() {
    if (isStop()) {
        return;/*ww  w .  j a  v a 2s.c  o  m*/
    }

    PermitMonitor permitMonitor = ArbitrateFactory.getInstance(getPipelineId(), PermitMonitor.class);
    ChannelStatus status = permitMonitor.getChannelPermit(true);
    if (status.isStop()) {
        return; // ?
    }

    Long nid = ArbitrateConfigUtils.getCurrentNid();
    String path = StagePathUtils.getMainStem(getPipelineId());

    MainStemEventData data = new MainStemEventData();
    data.setStatus(MainStemEventData.Status.TAKEING);
    data.setPipelineId(getPipelineId());
    data.setNid(nid);// ?nid
    // ?
    byte[] bytes = JsonUtils.marshalToByte(data);
    try {
        mutex.set(false);
        zookeeper.create(path, bytes, CreateMode.EPHEMERAL);
        activeData = data;
        processActiveEnter();// ?
        mutex.set(true);
    } catch (ZkNodeExistsException e) {
        bytes = zookeeper.readData(path, true);
        if (bytes == null) {// ???
            initMainstem();
        } else {
            activeData = JsonUtils.unmarshalFromByte(bytes, MainStemEventData.class);
            if (nid.equals(activeData.getNid())) { // reload???
                mutex.set(true);
            }
        }
    }
}

From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginView.java

/**
 * // w  w  w  .  j a  va2  s  .c  o m
 * @param path int of the path to get the Time Options for
 * @param storedTimePref Long of anytime during the specific day that we want to return times for
 * @return populates the "times" TreeSet (time longs truncated at the "the seconds" position) 
 *          which populates Time Combo box, the truncTimeToFullTimeMap which maps the truncated times
 *          im times TreeSet to each times full Long value. The truncTimeToFullTimeMap chooses each time
 *          up to the second and maps it to the greatest equivalent time up to the milliseconds.
 *          
 */
protected void setTimeOptions(int path, Long storedTimePref) {
    try {
        timeSelectCombo.getItems().clear();
        overrideTimestamp = null;

        Date startDate = null, finishDate = null;
        if (storedTimePref != null) {
            StampBdb stampDb = Bdb.getStampDb();
            NidSet nidSet = new NidSet();
            nidSet.add(path);

            NidSetBI stamps = null;
            if (!storedTimePref.equals(getDefaultTime())) {
                startDate = getStartOfDay(new Date(storedTimePref));
                finishDate = getEndOfDay(new Date(storedTimePref));
                stamps = stampDb.getSpecifiedStamps(nidSet, startDate.getTime(), finishDate.getTime());
            } else {
                stamps = stampDb.getSpecifiedStamps(nidSet, Long.MIN_VALUE, Long.MAX_VALUE);
            }

            truncTimeToFullTimeMap.clear();
            times.clear();

            HashSet<Integer> stampSet = stamps.getAsSet();

            Date d = new Date(storedTimePref);
            if (dateIsLocalDate(d)) {
                // Get stamps of day
                Date todayStartDate = getStartOfDay(new Date());
                Date todayFinishDate = getEndOfDay(new Date());
                NidSetBI todayStamps = stampDb.getSpecifiedStamps(nidSet, todayStartDate.getTime(),
                        todayFinishDate.getTime());

                // If have stamps, no action, if not, show Latest and set stamps to latest stamp we have in stampset
                if (todayStamps.size() == 0) {
                    //                  timeSelectCombo.getItems().add(Long.MAX_VALUE);
                    NidSetBI allStamps = stampDb.getSpecifiedStamps(nidSet, Long.MIN_VALUE, Long.MAX_VALUE);
                    HashSet<Integer> allStampSet = allStamps.getAsSet();
                    SortedSet<Integer> s = new TreeSet<Integer>(allStampSet);
                    if (!s.isEmpty()) {
                        Integer stampToSet = s.last();
                        overrideTimestamp = stampDb.getPosition(stampToSet).getTime();
                        timeSelectCombo.getItems().add(Long.MAX_VALUE);
                        timeSelectCombo.setValue(Long.MAX_VALUE);
                    }
                }
            }

            this.pathDatesList.add(LocalDate.now());
            if (overrideTimestamp == null) {
                if (!stampSet.isEmpty()) {
                    enableTimeCombo(true);
                    for (Integer thisStamp : stampSet) {
                        Long fullTime = null;
                        Date stampDate;
                        LocalDate stampInstant = null;
                        try {
                            fullTime = stampDb.getPosition(thisStamp).getTime();
                            stampDate = new Date(fullTime);
                            stampInstant = stampDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        Calendar cal = Calendar.getInstance();
                        cal.setTime(new Date(fullTime));
                        cal.set(Calendar.MILLISECOND, 0); //Strip milliseconds
                        Long truncTime = cal.getTimeInMillis();

                        this.pathDatesList.add(stampInstant); //Build DatePicker
                        times.add(truncTime); //This can probably go, we don't populate hashmap like this at initialization
                        timeSelectCombo.getItems().add(truncTime);

                        if (truncTimeToFullTimeMap.containsKey(truncTime)) { //Build Truncated Time to Full Time HashMap
                            //If truncTimeToFullTimeMap has this key, is the value the newest time in milliseconds?
                            if (new Date(truncTimeToFullTimeMap.get(truncTime)).before(new Date(fullTime))) {
                                truncTimeToFullTimeMap.put(truncTime, fullTime);
                            }
                        } else {
                            truncTimeToFullTimeMap.put(truncTime, fullTime);
                        }
                    }
                } else {
                    //               disableTimeCombo(true);
                    //                  timeSelectCombo.getItems().add(Long.MAX_VALUE);
                    timeSelectCombo.setValue(Long.MAX_VALUE);
                    enableTimeCombo(true);
                    //               logger.error("Could not retreive any Stamps");
                }
            }
        }
    } catch (Exception e) {
        logger.error("Error setting the default Time Dropdown");
        e.printStackTrace();
    }
}

From source file:com.square.adherent.noyau.service.implementations.EspaceClientInternetServiceImpl.java

@Override
public InformationConnexionSimpleDto getInfoConnexionSimpleByNumClient(String numClient) {
    logger.debug(messageSourceUtil.get(MessageKeyUtil.LOGGER_DEBUG_RECUP_INFO_CONNECTION_SIMPLE_CLIENT,
            new String[] { String.valueOf(numClient) }));

    // Le login doit tre renseign
    if (numClient == null || "".equals(numClient.trim())) {
        throw new BusinessException(messageSourceUtil.get(MessageKeyUtil.ERROR_IDENTIFICATION_LOGIN_INCORRECT));
    }/*w w w. j a  v  a  2s. c o m*/

    final IdentifiantsConnexionDto identifiants = new IdentifiantsConnexionDto();
    identifiants.setLogin(numClient.trim());

    // Rcupration de la connexion
    final Long idNatureConnexionEspaceClient = adherentMappingService.getIdNatureConnexionEspaceClient();
    List<EspaceClientInternet> listeConnexions = espaceClientInternetDao
            .getListeEspaceClientInternetsByIdentifiantsAndNature(identifiants, idNatureConnexionEspaceClient,
                    null);

    // Si on ne trouve pas de connexion et le numro de client commence par 0, on ressaye sans tenir compte du 0.
    if (listeConnexions.size() == 0 && identifiants.getLogin().trim().startsWith("0")) {
        final String numeroClientSansZero = identifiants.getLogin().trim().substring(1);
        identifiants.setLogin(numeroClientSansZero);
        listeConnexions = espaceClientInternetDao.getListeEspaceClientInternetsByIdentifiantsAndNature(
                identifiants, idNatureConnexionEspaceClient, true);
    }

    // Il doit y avoir une connexion pour le client demand
    if (listeConnexions.size() != 1) {
        throw new BusinessException(
                messageSourceUtil.get(MessageKeyUtil.ERROR_MESSAGE_ESPACE_CLIENT_INTERNET_ADHERENT_INEXISTANT,
                        new String[] { numClient }));
    }

    final InformationConnexionSimpleDto infosConnexion = new InformationConnexionSimpleDto();
    // Rcupration de l'email
    final Long idNatureEmail = squareMappingService.getIdNatureEmailPersonnel();
    final CoordonneesDto coordonnees = personneService
            .rechercherCoordonneesParIdPersonne(listeConnexions.get(0).getUidPersonne());
    if (coordonnees != null && coordonnees.getEmails() != null) {
        for (EmailDto email : coordonnees.getEmails()) {
            if (email.getNatureEmail() != null
                    && idNatureEmail.equals(email.getNatureEmail().getIdentifiant())) {
                infosConnexion.setEmail(email.getAdresse());
                break;
            }
        }
    }
    infosConnexion.setMotDePasse(listeConnexions.get(0).getMotDePasse());
    return infosConnexion;
}