Package org.zeroexchange.model.user

Examples of org.zeroexchange.model.user.User


     * {@inheritDoc}
     */
    @Transactional
    @Override
    public void onEvent(UsersInvited event) {
        User currentUser = authorizedUserService.getCurrentUser();
        for(User invitee: event.getUsers()) {
            Contract contract = event.getContract();
            Invitation invitation = invitationDAO.getInvitation(currentUser.getId(), invitee.getId(), contract.getId());
            if(invitation == null) {
                invitation = new Invitation();
                invitation.setContract(contract);
                invitation.setInvitee(invitee);
                invitation.setInviter(currentUser);
View Full Code Here


    @Transactional
    public UserDetails loadUserByUsername(String userOpenId)
            throws UsernameNotFoundException, DataAccessException {
        OpenIdCredential credential = openIDCredentialDAO.findCredential(userOpenId);
        if(credential == null) {
            User newUser = userFactory.createNewUser();
           
            newUser.setDisplayName(userOpenId);
               
            credential = new OpenIdCredential();
            credential.setOpenIdIdentifier(userOpenId);
            newUser = userWriter.createUser(newUser);
            credentialsWriter.addCredential(newUser, credential);
        }   
        User user = credential == null ? null : credential.getUser();
        if(user == null) {
            throw new BusinessLogicException("Cannot obtain user by specified openId:" + userOpenId);
        }
        return new ZEUserDetails(Collections.<GrantedAuthority>singletonList(
                new GrantedAuthorityImpl(Role.ACEGITOKEN_USER)), user, credential);
View Full Code Here

        //Contract identity
        Contract contract = contractReader.getContract(contractId);
        resource.setContract(contract);
       
        //User
        User owner = userReader.getUser(ownerId);
        resource.setOwner(owner);
       
        return resource;
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer getCurrentUserId() {
        User user = getCurrentUser();
        return user == null ? null: user.getId();
    }
View Full Code Here

        }
        String userName = getCurrentUserName();
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if(authentication != null && !(authentication instanceof AnonymousAuthenticationToken)) {
            Credential credential = authTokenInformer.getCredentials(authentication);
            User user = credential == null ? null : credential.getUser();
            if(user == null) {
                throw new BusinessLogicException("Unknown user '" + userName + "'");
            }
            return user;
        }
View Full Code Here

    @Override
    @Transactional
    public ResourceTender save(ResourceTender tender) {
       
        //We should remove all existent tenders for this user and resource.
        User tenderOwner = tender.getUser();
        if(tenderOwner != null) {
            supplyDAO.remove(tenderOwner.getId(), tender.getResource().getId());
            needDAO.remove(tenderOwner.getId(), tender.getResource().getId());
        }

        //Save the new one...
        return tender instanceof Supply ?
                supplyDAO.save((Supply) tender) :
View Full Code Here

    public ResourceTender getUserTender(Resource resource, Integer userId) {
        if(userId == null) {
            return null;
        }
        for(ResourceTender tender: resource.getNeeds()) {
            User tenderOwner = tender.getUser();
            if(tenderOwner != null && userId.equals(tenderOwner.getId())) {
                return tender;
            }
        }
        for(ResourceTender tender: resource.getSupplies()) {
            User tenderOwner = tender.getUser();
            if(tenderOwner != null && userId.equals(tenderOwner.getId())) {
                return tender;
            }
        }
        return null;
    }
View Full Code Here

    @Override
    @Transactional
    public void reconcile(Resource resource, User consumer) {
        //Write-off cycle
        int consumersCount = 0;
        User supplier = null;
        Need consumerTender = null;
        Supply supplierTender = null;
        BigDecimal totalSuppliersPrice = BigDecimal.ZERO;
        BigDecimal totalConsumerAmount = BigDecimal.ZERO;
        for(Supply supply: resource.getSupplies()) {
View Full Code Here

            String assessmentType, BigDecimal businessQuality,
            String businessQualityComment) {
       
       
        //Find the supplier
        User supplier = null;
        Date date = new Date();
        boolean allowReputationUpdate = true;
        for(Supply supply: resource.getSupplies()) {
            User examinedUser = supply.getUser();
            if(examinedUser != null && supply.getAcceptDate() != null) {
                //We've found the supplier!
                supplier = examinedUser;
               
                //The full reputation support is allowed only for 'work difficulty' estimation
                if(supply.getPriceType() != PriceType.WORK_EFFORTS && new BigDecimal(3).compareTo(businessQuality) >= 0) {
                    allowReputationUpdate = false;
                }
            }
        }
        for(Need need: resource.getNeeds()) {
            User examinedUser = need.getUser();
            if(examinedUser != null && examinedUser.equals(evaluator) && need.getCompletionDate() == null) {
                needManager.completeTender(need);
            }
        }

        //Update the assessment
View Full Code Here

        Set<PayerData> usersEfforts = new HashSet<PayerData>();
        Set<User> contractUsers = new HashSet<User>();
        for(Resource resource: resources) {
            Set<Supply> supplies = resource.getSupplies();
            for(ResourceTender tender: supplies) {
                User tenderOwner = tender.getUser();
                if(tender.getAcceptDate() != null && tenderOwner != null && !contractUsers.contains(tenderOwner)) {
                    contractUsers.add(tenderOwner);
                }
            }
            Set<Supply> needs = resource.getSupplies();
            for(ResourceTender tender: needs) {
                User tenderOwner = tender.getUser();
                if(tender.getAcceptDate() != null && tenderOwner != null && !contractUsers.contains(tenderOwner)) {
                    contractUsers.add(tenderOwner);
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.zeroexchange.model.user.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.