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:org.openmeetings.app.remote.red5.ClientListManager.java

/**
 * get the current Moderator in this room
 * // w w w  .j av a 2s . c om
 * @param roomname
 * @return
 */
public synchronized List<RoomClient> getCurrentModeratorByRoom(Long room_id) {

    List<RoomClient> rclList = new LinkedList<RoomClient>();
    for (Iterator<String> iter = clientList.keySet().iterator(); iter.hasNext();) {
        String key = iter.next();
        RoomClient rcl = clientList.get(key);
        //
        log.debug("*..*unsetModerator ClientList key: " + rcl.getStreamid());
        //
        // Check if the Client is in the same room
        if (room_id != null && room_id.equals(rcl.getRoom_id()) && rcl.getIsMod()) {
            log.debug("found client who is the Moderator: " + rcl);
            rclList.add(rcl);
        }
    }

    return rclList;
}

From source file:com.idega.xroad.service.business.BPMCasesService.java

protected TaskInstanceW getTaskInstanceW(Case theCase, Long taskInstanceID) {
    if (theCase == null || taskInstanceID == null) {
        return null;
    }//from  w w  w  . j  av a 2s .com

    List<TaskInstanceW> taskInstances = getTaskInstancesW(theCase);
    if (ListUtil.isEmpty(taskInstances)) {
        return null;
    }

    for (TaskInstanceW taskInstance : taskInstances) {
        if (taskInstanceID.equals(taskInstance.getTaskInstanceId())) {
            return taskInstance;
        }
    }

    return null;
}

From source file:edu.wustl.geneconnect.postwork.MetadataManager.java

/**
 * Names of columns which can be used to join given 2 tables.
 * @param sourceTableId source table to be joined
 * @param targetTableId destination table to be joined
 * @return//from www .  j  av a 2s  .  co  m
 */
public String[] getJoiningColumnNames(Long sourceTableId, Long targetTableId) {
    TableJoinInformation tableJoinInformation = null;
    Iterator iterator = tableJoinMetaData.iterator();
    while (iterator.hasNext()) {
        tableJoinInformation = (TableJoinInformation) iterator.next();
        if (sourceTableId.equals(tableJoinInformation.getSourceTableId())
                && targetTableId.equals(tableJoinInformation.getDestinationTableId())) {
            String[] joinColumnNames = {
                    getColumnInformation(tableJoinInformation.getSourceColumnId()).getName(),
                    getColumnInformation(tableJoinInformation.getDestinationColumnId()).getName() };
            return joinColumnNames;
        }
    }
    Logger.log(
            "ERROR : Joining Column Information for tables " + getBaseTableInformation(sourceTableId).getName()
                    + " - " + getBaseTableInformation(targetTableId).getName() + " is not available.",
            Logger.FATAL);
    Logger.log("Please check the GC graph configuration file and GCMetadataPopulation.sql "
            + "in script folder and rerun the server.", Logger.FATAL);
    return null;
}

From source file:org.apache.syncope.core.persistence.beans.user.SyncopeUser.java

public Membership getMembership(final Long syncopeRoleId) {
    Membership result = null;//ww  w .  j  a  v a2  s .  co  m
    Membership membership;
    for (Iterator<Membership> itor = getMemberships().iterator(); result == null && itor.hasNext();) {

        membership = itor.next();
        if (membership.getSyncopeRole() != null && syncopeRoleId.equals(membership.getSyncopeRole().getId())) {

            result = membership;
        }
    }

    return result;
}

From source file:com.cosmosource.common.service.UserMgrManager.java

/**
 * @description:?????/* w  ww.ja  va  2 s.co  m*/
 * @author hj
 * @param String cardId
 * @return boolean
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public boolean checkAdmin(String cardId) {

    Long userid = (Long) Struts2Util.getSession().getAttribute(Constants.USER_ID);
    String orgId = Struts2Util.getSession().getAttribute(Constants.ORG_ID).toString();

    Map<String, Object> condtion = new HashMap<String, Object>();
    condtion.put("orgId", orgId);
    condtion.put("cardId", cardId);

    List<Map> listMap = sqlDao.findList("PersonnelUnitSQL.isUnitAdmin", condtion);
    Long useridCompare = 0l;
    if (null == listMap || listMap.size() == 0) {
        useridCompare = (Long) listMap.get(0).get("USERID");
    }
    return useridCompare.equals(userid);
}

From source file:com.redhat.rhn.frontend.action.groups.EditGroupAction.java

private void validate(DynaActionForm form, ActionErrors errors, RequestContext ctx) {

    String name = form.getString("name");
    String desc = form.getString("description");
    Long sgid = ctx.getParamAsLong("sgid");

    // Check if both values are entered
    if (StringUtils.isEmpty(name) || StringUtils.isEmpty(desc)) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("systemgroup.create.requirements"));
    }/*from w ww  .  j av  a 2 s .c o m*/

    // Check if sg already exists
    ManagedServerGroup newGroup = ServerGroupFactory.lookupByNameAndOrg(name, ctx.getCurrentUser().getOrg());

    // Ugly condition for two error cases:
    //     creating page + group name exists
    //     editing page + group name exists except our group
    if (((sgid == null) && (newGroup != null))
            || (sgid != null) && (newGroup != null) && (!sgid.equals(newGroup.getId()))) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("systemgroup.create.alreadyexists"));
    }

}

From source file:com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.StandardDataSnapshotService.java

protected boolean applyReportUnitChanges(ExecutionContext context, ReportContext reportContext,
        ReportUnit reportUnit, boolean copyDataSnapshot, String originalReportUri) {
    boolean dirtyReportUnit = false;

    Long currentSnapshotId = reportUnit.getDataSnapshotId();
    Long existingSnapshotId = copyDataSnapshot ? null : reportUnit.getDataSnapshotId();
    DataSnapshotPersistResult result = persistDataSnapshot(context, reportContext, existingSnapshotId);
    Long savedSnapshotId = result.getSavedSnapshotId();
    if (currentSnapshotId == null ? savedSnapshotId != null
            : (savedSnapshotId == null || !currentSnapshotId.equals(savedSnapshotId))) {
        // data snapshot Id has changed
        reportUnit.setDataSnapshotId(savedSnapshotId);
        dirtyReportUnit = true;/*w  ww  . j  a  va  2 s .co m*/
    }

    return dirtyReportUnit;
}

From source file:com.gsma.rcs.ri.sharing.SharingListView.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    getMenuInflater().inflate(R.menu.menu_log_sharing_item, menu);
    menu.findItem(R.id.menu_sharing_display).setVisible(false);
    // Get the list item position
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    Cursor cursor = (Cursor) mAdapter.getItem(info.position);
    Direction dir = Direction.valueOf(cursor.getInt(cursor.getColumnIndexOrThrow(HistoryLog.DIRECTION)));
    String mimeType = cursor.getString(cursor.getColumnIndexOrThrow(HistoryLog.MIME_TYPE));
    if (mimeType != null && Utils.isImageType(mimeType)) {
        if (Direction.INCOMING == dir) {
            Long transferred = cursor.getLong(cursor.getColumnIndexOrThrow(HistoryLog.TRANSFERRED));
            Long fileSize = cursor.getLong(cursor.getColumnIndexOrThrow(HistoryLog.FILESIZE));
            if (fileSize.equals(transferred)) {
                menu.findItem(R.id.menu_sharing_display).setVisible(true);
                return;
            }//from  w w w.j  a  v a 2 s.  co m
            return;
        }
        menu.findItem(R.id.menu_sharing_display).setVisible(true);
    }
}

From source file:de.hska.ld.recommendation.controller.RecommendationController.java

@Secured(Core.ROLE_USER)
@RequestMapping(method = RequestMethod.GET, value = "/{documentId}")
@Transactional(readOnly = false, noRollbackFor = NoSuchElementException.class)
public ResponseEntity<LDRecommendationDto> getRecommendations(@PathVariable Long documentId)
        throws IOException {
    Document document = documentService.findById(documentId);
    if (document.getTagList().size() == 0) {
        return new ResponseEntity<LDRecommendationDto>(HttpStatus.INTERNAL_SERVER_ERROR);
    }//from   www .j  a  v a 2 s  .c o  m
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    OIDCAuthenticationToken token = (OIDCAuthenticationToken) auth;
    SSSRecommResponseDto sssRecommResponseDto = sssClient.retrieveRecommendations(documentId,
            token.getAccessTokenValue());
    if (sssRecommResponseDto == null) {
        return new ResponseEntity<LDRecommendationDto>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    List<SSSUserRecommendationDto> sssUserRecommendationDtoList = sssRecommResponseDto.getUsers();
    List<LDRecommendationUserDto> userIdList = new ArrayList<>();
    List<LDRecommendationDocumentDto> documentIdList = new ArrayList<>();
    sssUserRecommendationDtoList.forEach(ur -> {
        String userUri = ur.getUser().getId();
        // 1. Determine if the result is a user or a document
        if (userUri != null && userUri.contains("/user/")) {
            // 1.1 it is a user instance
            String[] splittedUserId = userUri.split("/user/");
            String userId = splittedUserId[splittedUserId.length - 1];
            Double likelihood = ur.getLikelihood();
            try {
                LDRecommendationUserDto ldRecommendationUserDto = new LDRecommendationUserDto();
                ldRecommendationUserDto.setUserId(Long.parseLong(userId));
                ldRecommendationUserDto.setLikelihood(likelihood);
                userIdList.add(ldRecommendationUserDto);
            } catch (Exception e) {
                //
            }
        } else if (userUri != null && userUri.contains("/document/")) {
            // 1.2 it is a document instance
            String[] splittedDocumentId = userUri.split("/document/");
            String documentIdRecommended = splittedDocumentId[splittedDocumentId.length - 1];
            Double likelihood = ur.getLikelihood();
            try {
                LDRecommendationDocumentDto ldRecommendationDocumentDto = new LDRecommendationDocumentDto();
                ldRecommendationDocumentDto.setDocumentId(Long.parseLong(documentIdRecommended));
                ldRecommendationDocumentDto.setLikelihood(likelihood);
                documentIdList.add(ldRecommendationDocumentDto);
            } catch (Exception e) {
                //
            }
        }
    });

    // fetch the related data sets from the living documents db
    List<LDRecommendationUserDto> userList = documentRecommInfoService
            .fetchUserRecommendationDatasets(userIdList);
    List<LDRecommendationDocumentDto> documentList = documentRecommInfoService
            .fetchDocumentRecommendationDatasets(documentIdList);

    try {
        Collections.sort(userList);
        Collections.sort(documentList);
    } catch (Exception e) {
        e.printStackTrace();
    }

    Long currenUserId = Core.currentUser().getId();
    User initialLoadUser = userService.findByUsername("aur0rp3");

    // filter out current user
    LDRecommendationUserDto found1 = null;
    LDRecommendationUserDto foundInit = null;
    List<LDRecommendationUserDto> likelihood0Users = new ArrayList<LDRecommendationUserDto>();
    for (LDRecommendationUserDto userRecomm : userList) {
        /*if (0d == userRecomm.getLikelihood()) {
        likelihood0Users.add(userRecomm);
        }*/
        if (currenUserId.equals(userRecomm.getUserId())) {
            found1 = userRecomm;
        }
        if (initialLoadUser != null && initialLoadUser.getId().equals(userRecomm.getUserId())) {
            foundInit = userRecomm;
        }
    }
    if (found1 != null) {
        userList.remove(found1);
    }
    if (foundInit != null) {
        userIdList.remove(foundInit);
    }
    if (likelihood0Users.size() > 0) {
        userList.removeAll(likelihood0Users);
    }

    // filter out current document
    LDRecommendationDocumentDto found = null;
    List<LDRecommendationDocumentDto> likelihood0Documents = new ArrayList<LDRecommendationDocumentDto>();
    for (LDRecommendationDocumentDto documentRecomm : documentList) {
        if (0d == documentRecomm.getLikelihood()) {
            likelihood0Documents.add(documentRecomm);
        }
        if (documentId.equals(documentRecomm.getDocumentId())) {
            found = documentRecomm;
        }
    }
    if (found != null) {
        documentList.remove(found);
    }
    if (likelihood0Documents.size() > 0) {
        documentList.removeAll(likelihood0Documents);
    }

    // filter out documents the current user has no access to
    List<LDRecommendationDocumentDto> noPermissionDocuments = new ArrayList<LDRecommendationDocumentDto>();
    for (LDRecommendationDocumentDto documentRecomm : documentList) {
        Long documentIdPermissionCheck = documentRecomm.getDocumentId();
        Document document2 = documentService.findById(documentIdPermissionCheck);
        if (!documentService.checkPermissionSave(document2, Access.Permission.READ)) {
            noPermissionDocuments.add(documentRecomm);
        }
    }
    if (noPermissionDocuments.size() > 0) {
        documentList.removeAll(noPermissionDocuments);
    }

    LDRecommendationDto ldRecommendationDto = new LDRecommendationDto();
    ldRecommendationDto.setUserList(new ArrayList<>());
    ldRecommendationDto.setDocumentList(documentList);
    ldRecommendationDto.setDocumentId(documentId);

    return new ResponseEntity<LDRecommendationDto>(ldRecommendationDto, HttpStatus.OK);
}

From source file:org.geoserver.geofence.services.servicetest.MainTest.java

private void setUpTestRule() {

    ShortGroup sp1 = new ShortGroup();
    sp1.setName("test_profile");

    long p1id = userGroupAdminService.insert(sp1);

    ShortGroup sp2 = new ShortGroup();
    sp2.setName("test_profile2");

    long p2id = userGroupAdminService.insert(sp2);
    UserGroup p2 = userGroupAdminService.get(p2id);

    GFUser u0 = new GFUser();
    u0.setName("admin");
    u0.setPassword("password");
    u0.setEnabled(true);/*from  w w  w  . ja  v a  2  s  . c o  m*/
    u0.setFullName("Sample G.F. Admin");
    u0.setEmailAddress("gf.admin@geofence.net");
    u0.setExtId("sample_geoserver_user");
    gfUserAdminService.insert(u0);

    GSUser u1 = new GSUser();
    u1.setAdmin(true);
    u1.setName("admin");
    u1.setPassword("password");
    u1.getGroups().add(userGroupAdminService.get(p1id));
    u1.setEnabled(true);
    u1.setFullName("Sample G.S. Admin");
    u1.setEmailAddress("gs.admin@geofence.net");
    u1.setExtId("sample_geoserver_user");
    userAdminService.insert(u1);

    GSInstance gs1 = new GSInstance();
    gs1.setName("geoserver01");
    gs1.setUsername("admin");
    gs1.setPassword("geoserver");
    gs1.setBaseURL("http://localhost/geoserver");
    gs1.setDescription("A sample instance");
    instanceAdminService.insert(gs1);

    Rule r0 = new Rule(5, u1.getName(), p2.getName(), gs1, null, "s0", "r0", null, null, GrantType.ALLOW);
    ruleAdminService.insert(r0);

    final Long r1id;

    {
        Rule r1 = new Rule(10, null, null, null, null, "s1", "r1", "w1", "l1", GrantType.ALLOW);
        ruleAdminService.insert(r1);
        r1id = r1.getId();
    }

    // save details and check it has been saved
    final Long lid1;
    {
        LayerDetails details = new LayerDetails();
        details.getAllowedStyles().add("FIRST_style1");
        details.getAttributes().add(new LayerAttribute("FIRST_attr1", AccessType.NONE));
        ruleAdminService.setDetails(r1id, details);
        lid1 = details.getId();
        assert lid1 != null;
    }

    // check details have been set in Rule
    {
        Rule loaded = ruleAdminService.get(r1id);
        LayerDetails details = loaded.getLayerDetails();
        assert details != null;
        assert lid1.equals(details.getId());
        assert 1 == details.getAttributes().size();
        assert 1 == details.getAllowedStyles().size();
        LOGGER.info("Found " + loaded + " --> " + loaded.getLayerDetails());
    }

    // set new details
    final Long lid2;
    {
        LayerDetails details = new LayerDetails();
        details.getAttributes().add(new LayerAttribute("attr1", AccessType.NONE));
        details.getAttributes().add(new LayerAttribute("attr2", AccessType.READONLY));
        details.getAttributes().add(new LayerAttribute("attr3", AccessType.READWRITE));

        assert 3 == details.getAttributes().size();

        Set<String> styles = new HashSet<String>();
        styles.add("style1");
        styles.add("style2");
        ruleAdminService.setAllowedStyles(r1id, styles);

        ruleAdminService.setDetails(r1id, details);
        lid2 = details.getId();
        assert lid2 != null;
    }

    // check details
    {
        Rule loaded = ruleAdminService.get(r1id);
        LayerDetails details = loaded.getLayerDetails();
        assert details != null;
        for (LayerAttribute layerAttribute : details.getAttributes()) {
            LOGGER.error(layerAttribute);
        }

        assert 3 == details.getAttributes().size();
        assert 2 == details.getAllowedStyles().size();
        assert details.getAllowedStyles().contains("style1");
    }

}