All Downloads are FREE. Search and download functionalities are using the official Maven repository.

services.FlexUserService Maven / Gradle / Ivy

There is a newer version: 1.2.3
Show newest version
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package services;

import db.FlexUser;
import java.util.Collection;
import java.util.HashMap;
import javax.ejb.Stateless;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import org.neo4j.ogm.cypher.query.SortOrder;

/**
 *
 * @author zua
 */

@TransactionManagement(TransactionManagementType.CONTAINER)
@Stateless
public class FlexUserService extends AbstractDBService implements FlexUserServiceInterface {

    @Override
    public Class getClassType() {
        return FlexUser.class;
    }

    @Override
    public FlexUser login(String username, String password) {
        System.out.println("INSIDE FLEX USER SERVICE ");
        String query = UsersQueries.findUser(username, password);
        return getSession().queryForObject(FlexUser.class, query, new HashMap<>());
    }

    @Override
    public FlexUser register(String username, String password) {
        getSession().save(new FlexUser(username, password));
        return login(username, password);
    }

    
    @Override
    public SortOrder getSortOrderAsc() {
        return new SortOrder().add(SortOrder.Direction.ASC, "username");
    }

    @Override
    public SortOrder getSortOrderDesc() {
        return new SortOrder().add(SortOrder.Direction.DESC, "username");
    }

    @Override
    public Collection findAllUsers() {
        return getSession().loadAll(getClassType(), getSortOrderDesc(), 2);
    }

    @Override
    public FlexUser findUserNamed(String username) {
        return getSession().load(getClassType(), username, 2);
    }

    @Override
    public void delete(FlexUser user) {
        super.delete(user.getUsername());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy