UserPropertyBean.java 1.85 KB
/*
 * Copyright Codecrew Ry
 *
 * All rights reserved.
 *
 * This license applies to any software containing a notice placed by the
 * copyright holder. Such software is herein referred to as the Software.
 * This license covers modification, distribution and use of the Software.
 *
 * Any distribution and use in source and binary forms, with or without
 * modification is not permitted without explicit written permission from the
 * copyright owner.
 *
 * A non-exclusive royalty-free right is granted to the copyright owner of the
 * Software to use, modify and distribute all modifications to the Software in
 * future versions of the Software.
 *
 */
package fi.codecrew.moya.beans;

import fi.codecrew.moya.facade.EventUserpropertyFacade;
import fi.codecrew.moya.facade.UserEventUserpropertyFacade;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.EventUserproperty;
import fi.codecrew.moya.model.UsersEventUserproperty;

import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import java.util.List;

@Stateless
@LocalBean
public class UserPropertyBean implements UserPropertyBeanLocal {

	@EJB
	private EventUserpropertyFacade eventPropertyFacade;
	@EJB
	private UserEventUserpropertyFacade userPropertyFacade;

	@EJB
	private PermissionBean permbean;

	public UserPropertyBean() {
	}

	@Override
	public List<EventUserproperty> getPropertiesForUser(EventUser user) {
		return eventPropertyFacade.findForUser(user);
	}

	@Override
	public List<UsersEventUserproperty> getUserPropertiesForUser(EventUser user) {
		return userPropertyFacade.findForUser(user);
	}

	@Override
	public UsersEventUserproperty saveUserproperty(UsersEventUserproperty prop) {
		if (prop == null) {
			return null;
		}
		if (prop.getId() == null) {
			userPropertyFacade.create(prop);
		} else {
			prop = userPropertyFacade.merge(prop);
		}
		return prop;


	}


}