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

fi.evolver.ai.vaadin.UserProfileRepository Maven / Gradle / Ivy

The newest version!
package fi.evolver.ai.vaadin;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import fi.evolver.ai.vaadin.entity.UserProfile;
import fi.evolver.ai.vaadin.util.AuthUtils;


@Repository
@Transactional
public interface UserProfileRepository extends JpaRepository {

	public UserProfile findUserProfileByUsername(String username);

	default UserProfile findOrCreateUserProfile() {
		String username = AuthUtils.getEmail();
		if (username == null)
			return null;
			
		UserProfile profile = findUserProfileByUsername(username);
		if (profile != null)
			return profile;

		profile = new UserProfile(username);
		save(profile);

		return profile;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy