Commit cdbf1659 authored by michael.simon's avatar michael.simon
Browse files

optimize data model for attribute sources

parent 4c7a9a37
......@@ -74,5 +74,4 @@ public class ASUserAttrEntity extends AbstractBaseEntity {
public void setValues(Set<ASUserAttrValueEntity> values) {
this.values = values;
}
}
......@@ -11,6 +11,7 @@
package edu.kit.scc.webreg.entity.as;
import java.util.Map;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
......@@ -20,6 +21,7 @@ import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinTable;
import javax.persistence.MapKeyColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.Fetch;
......@@ -53,6 +55,9 @@ public class AttributeSourceEntity extends AbstractBaseEntity {
@Column(name = "service_source")
private Boolean serviceSource;
@OneToMany(targetEntity = AttributeSourceServiceEntity.class, mappedBy="attributeSource")
private Set<AttributeSourceServiceEntity> attributeSourceServices;
public String getName() {
return name;
}
......@@ -92,4 +97,13 @@ public class AttributeSourceEntity extends AbstractBaseEntity {
public void setServiceSource(Boolean serviceSource) {
this.serviceSource = serviceSource;
}
public Set<AttributeSourceServiceEntity> getAttributeSourceServices() {
return attributeSourceServices;
}
public void setAttributeSourceServices(
Set<AttributeSourceServiceEntity> attributeSourceServices) {
this.attributeSourceServices = attributeSourceServices;
}
}
/*******************************************************************************
* 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.entity.as;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import edu.kit.scc.webreg.entity.AbstractBaseEntity;
import edu.kit.scc.webreg.entity.UserEntity;
@Entity(name = "AttributeSourceUserEntity")
@Table(name = "attribute_src_user")
public class AttributeSourceUserEntity extends AbstractBaseEntity {
private static final long serialVersionUID = 1L;
@ManyToOne
@JoinColumn(name = "user_id", nullable = false)
private UserEntity user;
@ManyToOne
@JoinColumn(name = "attribute_src_id", nullable = false)
private AttributeSourceEntity attributeSource;
public AttributeSourceEntity getAttributeSource() {
return attributeSource;
}
public void setAttributeSource(AttributeSourceEntity attributeSource) {
this.attributeSource = attributeSource;
}
public UserEntity getUser() {
return user;
}
public void setUser(UserEntity user) {
this.user = user;
}
}
......@@ -11,5 +11,4 @@ public interface AttributeSourceQueryService extends Serializable {
void updateUserAttributes(UserEntity user,
AttributeSourceEntity attributeSource, String executor)
throws RegisterException;
}
......@@ -19,6 +19,7 @@ import edu.kit.scc.webreg.dao.as.AttributeSourceDao;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.entity.as.ASUserAttrEntity;
import edu.kit.scc.webreg.entity.as.AttributeSourceEntity;
import edu.kit.scc.webreg.entity.as.AttributeSourceServiceEntity;
import edu.kit.scc.webreg.exc.RegisterException;
import edu.kit.scc.webreg.service.reg.AttributeSourceQueryService;
......@@ -67,6 +68,10 @@ public class AttributeSourceQueryServiceImpl implements AttributeSourceQueryServ
asUserAttr = asUserAttrDao.persist(asUserAttr);
}
for (AttributeSourceServiceEntity asse : attributeSource.getAttributeSourceServices()) {
logger.debug("Attributes requested for service {}", asse.getService().getName());
}
AttributeSourceWorkflow workflow = getWorkflowInstance(attributeSource.getAsClass());
AttributeSourceAuditor auditor = new AttributeSourceAuditor(auditDao, auditDetailDao, appConfig);
......
......@@ -20,7 +20,9 @@ import javax.inject.Inject;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.entity.as.ASUserAttrEntity;
import edu.kit.scc.webreg.entity.as.AttributeSourceEntity;
import edu.kit.scc.webreg.service.ASUserAttrService;
import edu.kit.scc.webreg.service.AttributeSourceService;
import edu.kit.scc.webreg.service.UserService;
import edu.kit.scc.webreg.util.SessionManager;
......@@ -34,6 +36,7 @@ public class UserAttributeSourcesBean implements Serializable {
private List<ASUserAttrEntity> userAttrList;
private ASUserAttrEntity selectedUserAttr;
private AttributeSourceEntity selectedAttributeSource;
@Inject
private UserService userService;
......@@ -41,6 +44,9 @@ public class UserAttributeSourcesBean implements Serializable {
@Inject
private ASUserAttrService asUserAttrService;
@Inject
private AttributeSourceService attributeSourceService;
@Inject
private SessionManager sessionManager;
......@@ -73,6 +79,12 @@ public class UserAttributeSourcesBean implements Serializable {
public void setSelectedUserAttr(ASUserAttrEntity selectedUserAttr) {
selectedUserAttr = asUserAttrService.findByIdWithAttrs(selectedUserAttr.getId(), "values");
selectedAttributeSource = attributeSourceService.findByIdWithAttrs(
selectedUserAttr.getAttributeSource().getId(), "attributeSourceServices");
this.selectedUserAttr = selectedUserAttr;
}
public AttributeSourceEntity getSelectedAttributeSource() {
return selectedAttributeSource;
}
}
......@@ -64,8 +64,15 @@
<p:dialog id="dialog" header="Detail" showEffect="fade" widgetVar="documentDialog" modal="true" resizable="false">
<p:outputPanel id="documentPanel">
<p:panelGrid columns="2" columnClasses="label,value" rendered="#{not empty userAttributeSourcesBean.selectedUserAttr}">
<h:outputLabel for="name2" value="#{messages.name}" />
<h:outputText id="name2" value="#{userAttributeSourcesBean.selectedUserAttr.attributeSource.name}" />
<h:outputLabel value="#{messages.attribute_sources}" />
<p:dataList var="ass" value="#{userAttributeSourcesBean.selectedAttributeSource.attributeSourceServices.toArray()}">
<h:outputText value="#{ass.service.name}" />
</p:dataList>
</p:panelGrid>
<p:dataTable var="v" value="#{userAttributeSourcesBean.selectedUserAttr.values.toArray()}">
<p:column style="width:128px">
......
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