Commit 669f4f20 authored by michael.simon's avatar michael.simon
Browse files

Add connection between services and sp

parent c39318f3
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.dao;
import java.util.List;
import edu.kit.scc.webreg.entity.SamlSpMetadataEntity;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.entity.ServiceSamlSpEntity;
public interface ServiceSamlSpDao extends BaseDao<ServiceSamlSpEntity, Long> {
List<ServiceSamlSpEntity> findByService(ServiceEntity service);
List<ServiceSamlSpEntity> findBySamlSp(SamlSpMetadataEntity sp);
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.dao.jpa;
import java.util.List;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import edu.kit.scc.webreg.dao.ServiceSamlSpDao;
import edu.kit.scc.webreg.entity.SamlSpMetadataEntity;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.entity.ServiceSamlSpEntity;
@Named
@ApplicationScoped
public class JpaServiceSamlSpDao extends JpaBaseDao<ServiceSamlSpEntity, Long> implements ServiceSamlSpDao {
@Override
public List<ServiceSamlSpEntity> findByService(ServiceEntity service) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<ServiceSamlSpEntity> criteria = builder.createQuery(ServiceSamlSpEntity.class);
Root<ServiceSamlSpEntity> root = criteria.from(ServiceSamlSpEntity.class);
criteria.where(
builder.equal(root.get("service"), service));
criteria.select(root);
return em.createQuery(criteria).getResultList();
}
@Override
public List<ServiceSamlSpEntity> findBySamlSp(SamlSpMetadataEntity sp) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<ServiceSamlSpEntity> criteria = builder.createQuery(ServiceSamlSpEntity.class);
Root<ServiceSamlSpEntity> root = criteria.from(ServiceSamlSpEntity.class);
criteria.where(
builder.equal(root.get("sp"), sp));
criteria.select(root);
return em.createQuery(criteria).getResultList();
}
@Override
public Class<ServiceSamlSpEntity> getEntityClass() {
return ServiceSamlSpEntity.class;
}
}
package edu.kit.scc.webreg.entity;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity(name = "ServiceSamlSpEntity")
@Table(name = "service_saml_sp")
public class ServiceSamlSpEntity extends AbstractBaseEntity {
private static final long serialVersionUID = 1L;
@ManyToOne(targetEntity = ServiceEntity.class)
private ServiceEntity service;
@ManyToOne(targetEntity = SamlSpMetadataEntity.class)
private SamlSpMetadataEntity sp;
@ManyToOne (targetEntity = ScriptEntity.class)
private ScriptEntity script;
public ServiceEntity getService() {
return service;
}
public void setService(ServiceEntity service) {
this.service = service;
}
public SamlSpMetadataEntity getSp() {
return sp;
}
public void setSp(SamlSpMetadataEntity sp) {
this.sp = sp;
}
public ScriptEntity getScript() {
return script;
}
public void setScript(ScriptEntity script) {
this.script = script;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment