Example usage for java.util UUID equals

List of usage examples for java.util UUID equals

Introduction

In this page you can find the example usage for java.util UUID equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:eu.carrade.amaury.BallsOfSteel.BoSTeam.java

/**
 * Returns true if the given player is in this team.
 * /* w w w. j  a  v a  2s  .  c o  m*/
 * @param player The player to check.
 * @return true if the given player is in this team.
 */
public boolean containsPlayer(Player player) {
    Validate.notNull(player, "The player cannot be null.");

    for (UUID playerInTeamID : players) {
        if (playerInTeamID.equals(player.getUniqueId())) {
            return true;
        }
    }
    return false;
}

From source file:org.usergrid.tools.DupOrgRepair.java

/**
 * Merge the source orgId into the targetId in the following way.
 * //www .java 2  s .  c  o m
 * 1) link all admins from the source org to the target org 2) link all apps
 * from the source org to the target or 3) delete the target org
 * 
 * @param sourceOrgId
 * @param targetOrgId
 * @throws Exception
 */
@SuppressWarnings("unchecked")
private void mergeOrganizations(String outputDir, UUID sourceOrgId, UUID targetOrgId) throws Exception {

    OrganizationInfo sourceOrgInfo = managementService.getOrganizationByUuid(sourceOrgId);

    Map<String, Object> sourceOrg = managementService.getOrganizationData(sourceOrgInfo);

    OrganizationInfo targetOrgInfo = managementService.getOrganizationByUuid(targetOrgId);

    Map<String, Object> targetOrg = managementService.getOrganizationData(targetOrgInfo);

    // Dump the output on these two orgs
    FileWriter file = new FileWriter(
            String.format("%s/%s.%s.orig", outputDir, sourceOrgInfo.getName(), sourceOrgId));

    file.write(JsonUtils.mapToFormattedJsonString(sourceOrg));

    file.write("\n\n");

    file.write(JsonUtils.mapToFormattedJsonString(targetOrg));

    file.flush();
    file.close();

    // BiMap<UUID, String> targetApps =
    // managementService.getApplicationsForOrganization(targetOrgId);

    // now perform the merge

    // add all the admins
    Map<String, UserInfo> admins = (Map<String, UserInfo>) sourceOrg.get("users");

    for (Entry<String, UserInfo> adminEntry : admins.entrySet()) {
        UserInfo admin = adminEntry.getValue();

        logger.info("adding admin with uuid {} and email {} to org with name {} and uuid {}", new Object[] {
                admin.getUuid(), admin.getEmail(), targetOrgInfo.getName(), targetOrgInfo.getUuid() });

        // copy the admins over
        managementService.addAdminUserToOrganization(admin, targetOrgInfo, false);
    }

    // get the root entity manager
    EntityManager em = emf.getEntityManager(CassandraService.MANAGEMENT_APPLICATION_ID);

    // Add the apps to the org
    Map<String, UUID> sourceApps = (Map<String, UUID>) sourceOrg.get("applications");

    Map<String, UUID> targetApps = (Map<String, UUID>) targetOrg.get("applications");

    for (Entry<String, UUID> app : sourceApps.entrySet()) {

        // we have colliding app names
        if (targetApps.get(app.getKey()) != null) {

            // already added, skip it
            if (app.getValue().equals(targetApps.get(app.getKey()))) {
                continue;
            }

            // check to see if this orgname/appname lookup returns the app we're
            // about to re-assign. If it does NOT, then we need to rename this app
            // before performing the link.
            UUID appIdToKeep = emf.lookupApplication(app.getKey());

            UUID appIdToChange = appIdToKeep.equals(app.getValue()) ? targetApps.get(app.getKey())
                    : app.getValue();

            // get the existing target entity
            Entity appEntity = em.get(appIdToChange);

            if (appEntity != null) {

                String oldName = appEntity.getProperty("name").toString();
                String newName = oldName + appEntity.getUuid();

                //force the property to be updated
                em.setProperty(appEntity, "name", newName, true);

                logger.info("Renamed app from {} to {}", oldName, newName);

            }
        }

        logger.info("Adding application with name {} and id {} to organization with uuid {}",
                new Object[] { app.getKey(), app.getValue(), targetOrgId });
        managementService.addApplicationToOrganization(targetOrgId, app.getValue());
    }

    // now delete the original org

    logger.info("Deleting org with the name {} and uuid {}", sourceOrgInfo.getName(), sourceOrgInfo.getUuid());

    // delete the source org
    em.delete(new SimpleEntityRef("group", sourceOrgId));

    // re-dump the target from the cassandra stat
    targetOrgInfo = managementService.getOrganizationByUuid(targetOrgId);

    targetOrg = managementService.getOrganizationData(targetOrgInfo);

    file = new FileWriter(String.format("%s/%s.%s.new", outputDir, targetOrgInfo.getName(), targetOrgId));

    file.write(JsonUtils.mapToFormattedJsonString(targetOrg));

    file.flush();
    file.close();

}

From source file:org.jasig.ssp.web.api.reports.CaseloadReportController.java

private List<CaseLoadReportTO> collectCaseLoadReportTOs(CaseLoadSearchTO searchForm) {
    List<CaseLoadReportTO> caseLoadReportList = Lists.newArrayList();

    final Collection<CoachCaseloadRecordCountForProgramStatus> countsByCoachAndStatus = caseLoadService
            .currentCaseloadCountsByStatus(searchForm);
    UUID currentCoachId = null;
    CaseLoadReportTO caseLoadReportTO = null;
    for (CoachCaseloadRecordCountForProgramStatus countByCoachAndStatus : countsByCoachAndStatus) {
        if (currentCoachId == null || !(currentCoachId.equals(countByCoachAndStatus.getCoachId()))) {
            if (caseLoadReportTO != null) {
                caseLoadReportList.add(caseLoadReportTO);
            }/*w ww .  j a v  a  2  s .  c o  m*/
            currentCoachId = countByCoachAndStatus.getCoachId();
            caseLoadReportTO = new CaseLoadReportTO(countByCoachAndStatus.getCoachFirstName(),
                    countByCoachAndStatus.getCoachLastName(),
                    departmentNameOrDefault(countByCoachAndStatus, DEPARTMENT_PLACEHOLDER));
        }
        ProgramStatusHelper.maybeAddToCount(countByCoachAndStatus.getCount(), caseLoadReportTO,
                countByCoachAndStatus.getProgramStatusId());
    }
    // make sure last one isn't forgotten
    if (caseLoadReportTO != null) {
        caseLoadReportList.add(caseLoadReportTO);
    }
    return caseLoadReportList;
}

From source file:com.azaptree.services.security.commands.subjectRepository.DeleteSubjectCredential.java

public DeleteSubjectCredential() {
    setValidator(new CommandContextValidatorSupport() {

        @Override// www .j a  v a  2 s  .  c o  m
        protected void checkInput(final Command command, final Context ctx) {
            final UUID subjectId = get(ctx, SUBJECT_ID);
            if (!subjectDAO.exists(subjectId)) {
                throw new UnknownSubjectException(subjectId.toString());
            }

            final UUID updatedBySubjectId = get(ctx, UPDATED_BY_SUBJECT_ID);
            if (updatedBySubjectId != null) {
                Assert.isTrue(!subjectId.equals(updatedBySubjectId), String.format(
                        "The updatedBy subject (%s) cannot be the same as the subject (%s) which we are adding the credential to",
                        subjectId, updatedBySubjectId));
                if (!subjectDAO.exists(updatedBySubjectId)) {
                    throw new UnknownSubjectException(
                            String.format("Subject for updatedBy does not exist: %s", updatedBySubjectId));
                }
            }

        }

        @Override
        protected void checkOutput(final Command command, final Context ctx) {
            // none required
        }

    });

    setInputKeys(SUBJECT_ID, CREDENTIAL_NAME, UPDATED_BY_SUBJECT_ID);
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrm.CFCrmHPKey.java

public boolean equals(Object obj) {
    if (obj == null) {
        return (false);
    } else if (obj instanceof CFCrmHPKey) {
        CFCrmHPKey rhs = (CFCrmHPKey) obj;
        {// w  w  w. j  a v  a  2  s .c om
            long lhsClusterId = getAuditClusterId();
            long rhsClusterId = rhs.getAuditClusterId();
            if (lhsClusterId != rhsClusterId) {
                return (false);
            }
        }
        {
            Calendar lhsAuditStamp = getAuditStamp();
            Calendar rhsAuditStamp = rhs.getAuditStamp();
            if (lhsAuditStamp != null) {
                if (rhsAuditStamp != null) {
                    if (!lhsAuditStamp.equals(rhsAuditStamp)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        {
            short lhsActionId = getAuditActionId();
            short rhsActionId = rhs.getAuditActionId();
            if (lhsActionId != rhsActionId) {
                return (false);
            }
        }
        {
            int lhsRevision = getRequiredRevision();
            int rhsRevision = rhs.getRequiredRevision();
            if (lhsRevision != rhsRevision) {
                return (false);
            }
        }
        {
            UUID lhsAuditSessionId = getAuditSessionId();
            UUID rhsAuditSessionId = rhs.getAuditSessionId();
            if (lhsAuditSessionId != null) {
                if (rhsAuditSessionId != null) {
                    if (!lhsAuditSessionId.equals(rhsAuditSessionId)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        return (true);
    } else {
        return (false);
    }
}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternet.CFInternetHPKey.java

public boolean equals(Object obj) {
    if (obj == null) {
        return (false);
    } else if (obj instanceof CFInternetHPKey) {
        CFInternetHPKey rhs = (CFInternetHPKey) obj;
        {//  www  .jav a  2 s .  co m
            long lhsClusterId = getAuditClusterId();
            long rhsClusterId = rhs.getAuditClusterId();
            if (lhsClusterId != rhsClusterId) {
                return (false);
            }
        }
        {
            Calendar lhsAuditStamp = getAuditStamp();
            Calendar rhsAuditStamp = rhs.getAuditStamp();
            if (lhsAuditStamp != null) {
                if (rhsAuditStamp != null) {
                    if (!lhsAuditStamp.equals(rhsAuditStamp)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        {
            short lhsActionId = getAuditActionId();
            short rhsActionId = rhs.getAuditActionId();
            if (lhsActionId != rhsActionId) {
                return (false);
            }
        }
        {
            int lhsRevision = getRequiredRevision();
            int rhsRevision = rhs.getRequiredRevision();
            if (lhsRevision != rhsRevision) {
                return (false);
            }
        }
        {
            UUID lhsAuditSessionId = getAuditSessionId();
            UUID rhsAuditSessionId = rhs.getAuditSessionId();
            if (lhsAuditSessionId != null) {
                if (rhsAuditSessionId != null) {
                    if (!lhsAuditSessionId.equals(rhsAuditSessionId)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        return (true);
    } else {
        return (false);
    }
}

From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurity.CFSecurityHPKey.java

public boolean equals(Object obj) {
    if (obj == null) {
        return (false);
    } else if (obj instanceof CFSecurityHPKey) {
        CFSecurityHPKey rhs = (CFSecurityHPKey) obj;
        {/*from   www . j  a v  a  2 s. c o  m*/
            long lhsClusterId = getAuditClusterId();
            long rhsClusterId = rhs.getAuditClusterId();
            if (lhsClusterId != rhsClusterId) {
                return (false);
            }
        }
        {
            Calendar lhsAuditStamp = getAuditStamp();
            Calendar rhsAuditStamp = rhs.getAuditStamp();
            if (lhsAuditStamp != null) {
                if (rhsAuditStamp != null) {
                    if (!lhsAuditStamp.equals(rhsAuditStamp)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        {
            short lhsActionId = getAuditActionId();
            short rhsActionId = rhs.getAuditActionId();
            if (lhsActionId != rhsActionId) {
                return (false);
            }
        }
        {
            int lhsRevision = getRequiredRevision();
            int rhsRevision = rhs.getRequiredRevision();
            if (lhsRevision != rhsRevision) {
                return (false);
            }
        }
        {
            UUID lhsAuditSessionId = getAuditSessionId();
            UUID rhsAuditSessionId = rhs.getAuditSessionId();
            if (lhsAuditSessionId != null) {
                if (rhsAuditSessionId != null) {
                    if (!lhsAuditSessionId.equals(rhsAuditSessionId)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        return (true);
    } else {
        return (false);
    }
}

From source file:org.midonet.config.TestHostIdGenerator.java

@Test
public void generateRandomId() throws Exception {
    // delete properties file
    boolean res = propFile.delete();
    Assert.assertTrue(res);/*w w  w  . j a  v a  2  s  . co m*/
    UUID id = HostIdGenerator.getHostId(configFake);
    // check that the id has been written in the property file
    boolean exists = propFile.exists();
    Assert.assertTrue(exists);
    Properties properties = new Properties();
    properties.load(new FileInputStream(localPropertiesFile));
    UUID idFromProperty = UUID.fromString(properties.getProperty(uuidPropertyName));
    Assert.assertTrue(id.equals(idFromProperty));
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAcc.CFAccHPKey.java

public boolean equals(Object obj) {
    if (obj == null) {
        return (false);
    } else if (obj instanceof CFAccHPKey) {
        CFAccHPKey rhs = (CFAccHPKey) obj;
        {/*from www  .j av  a2 s . com*/
            long lhsClusterId = getAuditClusterId();
            long rhsClusterId = rhs.getAuditClusterId();
            if (lhsClusterId != rhsClusterId) {
                return (false);
            }
        }
        {
            Calendar lhsAuditStamp = getAuditStamp();
            Calendar rhsAuditStamp = rhs.getAuditStamp();
            if (lhsAuditStamp != null) {
                if (rhsAuditStamp != null) {
                    if (!lhsAuditStamp.equals(rhsAuditStamp)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        {
            short lhsActionId = getAuditActionId();
            short rhsActionId = rhs.getAuditActionId();
            if (lhsActionId != rhsActionId) {
                return (false);
            }
        }
        {
            int lhsRevision = getRequiredRevision();
            int rhsRevision = rhs.getRequiredRevision();
            if (lhsRevision != rhsRevision) {
                return (false);
            }
        }
        {
            UUID lhsAuditSessionId = getAuditSessionId();
            UUID rhsAuditSessionId = rhs.getAuditSessionId();
            if (lhsAuditSessionId != null) {
                if (rhsAuditSessionId != null) {
                    if (!lhsAuditSessionId.equals(rhsAuditSessionId)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        return (true);
    } else {
        return (false);
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAst.CFAstHPKey.java

public boolean equals(Object obj) {
    if (obj == null) {
        return (false);
    } else if (obj instanceof CFAstHPKey) {
        CFAstHPKey rhs = (CFAstHPKey) obj;
        {// w w w  .ja v  a2 s  .c  om
            long lhsClusterId = getAuditClusterId();
            long rhsClusterId = rhs.getAuditClusterId();
            if (lhsClusterId != rhsClusterId) {
                return (false);
            }
        }
        {
            Calendar lhsAuditStamp = getAuditStamp();
            Calendar rhsAuditStamp = rhs.getAuditStamp();
            if (lhsAuditStamp != null) {
                if (rhsAuditStamp != null) {
                    if (!lhsAuditStamp.equals(rhsAuditStamp)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        {
            short lhsActionId = getAuditActionId();
            short rhsActionId = rhs.getAuditActionId();
            if (lhsActionId != rhsActionId) {
                return (false);
            }
        }
        {
            int lhsRevision = getRequiredRevision();
            int rhsRevision = rhs.getRequiredRevision();
            if (lhsRevision != rhsRevision) {
                return (false);
            }
        }
        {
            UUID lhsAuditSessionId = getAuditSessionId();
            UUID rhsAuditSessionId = rhs.getAuditSessionId();
            if (lhsAuditSessionId != null) {
                if (rhsAuditSessionId != null) {
                    if (!lhsAuditSessionId.equals(rhsAuditSessionId)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        return (true);
    } else {
        return (false);
    }
}