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:de.berlios.jhelpdesk.web.preferences.LookAndFeelEditController.java

private boolean isPrefsOwnedByUser(LookAndFeelPreferences laf, User user) {
    LookAndFeelPreferences userLaf = user.getLafPreferences();
    Long lafId = laf.getId();
    if (userLaf == null || lafId == null) {
        return false;
    }/*w  w  w  .  jav a  2s  . c o  m*/
    return lafId.equals(userLaf.getId());
}

From source file:de.sainth.recipe.backend.rest.controller.CookbookController.java

@Secured({ "ROLE_USER", "ROLE_ADMIN" })
@RequestMapping(value = "{id}", method = RequestMethod.PUT)
HttpEntity<Cookbook> update(@PathVariable("id") Long id, @Valid @RequestBody Cookbook cookbook) {
    if (id.equals(cookbook.getId())) {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if (authentication instanceof RecipeManagerAuthenticationToken) {
            RecipeManagerAuthenticationToken token = (RecipeManagerAuthenticationToken) authentication;
            Cookbook existingCookbook = repository.findOne(cookbook.getId());
            if (existingCookbook != null) {
                if (ROLE_ADMIN.name().equals(token.getRole())
                        || existingCookbook.getAuthor().getId().equals(authentication.getPrincipal())) {
                    repository.save(cookbook);
                    return new ResponseEntity<>(cookbook, HttpStatus.OK);
                } else {
                    return new ResponseEntity<>(HttpStatus.FORBIDDEN);
                }//from ww w  .  j av a2s  . c o  m
            }
        }
    }
    return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}

From source file:com.largecode.interview.rustem.controller.UsersController.java

private void checkUrlAndBodyForId(Long id, UserDto userDto) {
    if (!id.equals(userDto.getIdUser())) {
        throw new ExceptionDifferentIdBetweenUrlAndBody(String.format(
                "'idUser' in URL (%s) must be as same as in request body (%s)", id, userDto.getIdUser()));
    }//from w w w  . j a v a2 s. c  o m
}

From source file:com.mobileman.projecth.business.DiseaseTest.java

/**
 * //from www. ja va2 s  . c  om
 * @throws Exception
 */
@Test
public void save() throws Exception {

    diseaseService = (DiseaseService) applicationContext.getBean(ComponentNames.DISEASE_SERVICE);
    assertNotNull(diseaseService);

    DiseaseGroup diseaseGroup = new DiseaseGroup();
    diseaseGroup.setCode("code");
    diseaseGroup.setName("name");

    Long diseaseGroupId = diseaseService.saveGroup(diseaseGroup);
    assertNotNull(diseaseGroupId);
    assertTrue(!diseaseGroupId.equals(0L));

    DiseaseSubgroup diseaseSubgroup = new DiseaseSubgroup();
    diseaseSubgroup.setCode("code");
    diseaseSubgroup.setName("name");
    diseaseSubgroup.setDiseaseGroup(diseaseGroup);

    Long diseaseSubgroupId = diseaseService.saveSubgroup(diseaseSubgroup);
    assertNotNull(diseaseSubgroupId);
    assertTrue(!diseaseSubgroupId.equals(0L));

    Disease disease = new Disease();
    disease.setCode("code");
    disease.setName("name");
    disease.setImageName("imageName");
    disease.setDiseaseSubgroup(diseaseSubgroup);

    List<Disease> diseases = diseaseService.findAll();
    int oldSize = diseases.size();

    Long diseaseId = diseaseService.save(disease);
    assertNotNull(diseaseId);
    assertTrue(!diseaseId.equals(0L));

    diseases = diseaseService.findAll();
    assertTrue(diseases.size() == oldSize + 1);
}

From source file:com.healthcit.analytics.servlet.admin.AdminController.java

private User buildUser(UserModel userModel, Collection<Role> roles) {
    User user = new User(userModel.getId(), userModel.getUsername(),
            StringUtils.isBlank(userModel.getPassword()) ? null
                    : this.passwordEncoder.encodePassword(userModel.getPassword(), null),
            userModel.getEmail(), null);
    if (userModel.getRoles() != null) {
        for (Long roleId : userModel.getRoles()) {
            for (Role role : roles) {
                if (roleId.equals(role.getId())) {
                    user.getAuthorities().add(role);
                }//from w ww  .  j  a  va 2s . co  m
            }
        }
    }
    return user;
}

From source file:be.virtualsushi.jfx.dorse.control.table.MyRelatedPropertyValueFactory.java

private Article findArticleById(Long articleId) {
    for (Article article : articles) {
        if (articleId.equals(article.getId())) {
            return article;
        }/*from   www.  j a v  a2  s.c  om*/
    }
    throw new IllegalStateException("Article with id " + articleId + " doesn't exists.");
}

From source file:net.mindengine.oculus.frontend.web.controllers.api.report.ApiReportSuiteController.java

@PUT
@Path("/report/suite/(.*)/finished")
public void suiteFinish(@RequestVar(1) Long id) throws Exception {
    if (id == null || id.equals(0L)) {
        throw new IllegalArgumentException("Id of suite run is not specified");
    }/*from w  ww .  ja va2  s  .c o m*/
    testRunDAO.updateSuiteEndTime(id, new Date());
}

From source file:ome.testing.Paths.java

public Set unique(Long which, Long testCg, Long testC, Long testI) {
    if (which.equals(CG) || which.equals(C) || which.equals(I)) {
        Set retVal = find(testCg, testC, testI);
        Set collect = new HashSet();
        for (Iterator it = retVal.iterator(); it.hasNext();) {
            Long idx = (Long) it.next();
            Long[] values = get(idx);
            collect.add(values[which.intValue()]);
        }/*  w w w  . j  av a  2s  .c o m*/
        return collect;
    } else {
        throw new ApiUsageException(which + " is an unknown index.");
    }
}

From source file:com.jaspersoft.jasperserver.api.metadata.data.snapshot.hibernate.DataSnapshotReportUnitListener.java

public void afterSaveOrUpdate(SaveOrUpdateEvent event) {
    Object entity = event.getEntity();
    EntityEntry entityEntry = event.getEntry();
    if (entity instanceof RepoReportUnit && entityEntry != null && entityEntry.isExistsInDatabase()) {
        // delete the snapshot when a new one is set in a report unit
        RepoReportUnit reportUnit = (RepoReportUnit) entity;
        Long currentSnapshotId = reportUnit.getDataSnapshotId();
        Long oldSnapshotId = (Long) entityEntry.getLoadedValue("dataSnapshotId");
        if (oldSnapshotId != null && (currentSnapshotId == null || !oldSnapshotId.equals(currentSnapshotId))) {
            // delete the snapshot on report unit deletion
            if (log.isDebugEnabled()) {
                log.debug("deleting snapshot " + currentSnapshotId + " for report "
                        + reportUnit.getResourceURI() + ", replaced by " + currentSnapshotId);
            }//www .j  av  a  2s.com

            dataSnapshotService().deleteSnapshot(oldSnapshotId);
        }
    }
}

From source file:net.mindengine.oculus.frontend.web.controllers.issue.IssueEditController.java

@SuppressWarnings("unchecked")
@Override//from ww w.  j  av a 2 s  . c o m
protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception {
    Issue issue = (Issue) command;
    Map map = new HashMap<String, Object>();

    Long rootId = projectDAO.getProjectRootId(issue.getProjectId(), 10);
    map.put("rootProjectId", rootId);

    if (rootId.equals(issue.getProjectId()) && rootId > 0) {
        map.put("subprojects", projectDAO.getSubprojects(issue.getProjectId()));
    }
    map.put("customizationGroups", CustomizationUtils.fetchCustomizationGroups(customizationDAO, userDAO,
            rootId, issue.getId(), Customization.UNIT_ISSUE));
    map.put("title", getTitle());
    return map;
}