Commit 2ee15111 authored by michael.simon's avatar michael.simon
Browse files

introduce parent service into db model

parent f96b62ba
......@@ -45,6 +45,9 @@ public class ServiceEntity extends AbstractBaseEntity {
@Column(name="short_name", length=32, nullable=false, unique=true)
private String shortName;
@ManyToOne(targetEntity = ServiceEntity.class)
private ServiceEntity parentService;
@ManyToOne(targetEntity = AdminRoleEntity.class)
private AdminRoleEntity adminRole;
......@@ -258,4 +261,12 @@ public class ServiceEntity extends AbstractBaseEntity {
this.attributeSourceService = attributeSourceService;
}
public ServiceEntity getParentService() {
return parentService;
}
public void setParentService(ServiceEntity parentService) {
this.parentService = parentService;
}
}
......@@ -119,6 +119,14 @@ public class RegisterUserServiceImpl implements RegisterUserService {
@Override
public void registerUser(UserEntity user, ServiceEntity service, String executor)
throws RegisterException {
service = serviceDao.findById(service.getId());
if (service.getParentService() != null) {
logger.info("Service has Parent. Registering parent first.");
registerUser(user, service.getParentService(), executor);
}
RegistryEntity registry = registryDao.createNew();
try {
......
......@@ -64,6 +64,7 @@ public class EditServiceBean implements Serializable {
private ServiceEntity entity;
private List<ServiceEntity> parentServiceList;
private List<ApproverRoleEntity> approverRoleList;
private List<AdminRoleEntity> adminRoleList;
private List<AdminRoleEntity> hotlineRoleList;
......@@ -72,6 +73,7 @@ public class EditServiceBean implements Serializable {
private List<BusinessRuleEntity> ruleList;
private List<BusinessRulePackageEntity> rulePackageList;
private ServiceEntity selectedParentService;
private ApproverRoleEntity selectedApproverRole;
private AdminRoleEntity selectedAdminRole;
private AdminRoleEntity selectedHotlineRole;
......@@ -99,6 +101,8 @@ public class EditServiceBean implements Serializable {
imageList = imageService.findAll();
ruleList = ruleService.findAll();
rulePackageList = rulePackageService.findAll();
parentServiceList = service.findAll();
selectedApproverRole = entity.getApproverRole();
selectedAdminRole = entity.getAdminRole();
selectedHotlineRole = entity.getHotlineRole();
......@@ -107,6 +111,8 @@ public class EditServiceBean implements Serializable {
selectedRule = entity.getAccessRule();
selectedRulePackage = entity.getGroupFilterRulePackage();
selectedMandatoryValuesRulePackage = entity.getMandatoryValueRulePackage();
selectedParentService = entity.getParentService();
propertyMap = new HashMap<String, String>(entity.getServiceProps());
initialized = true;
}
......@@ -122,6 +128,7 @@ public class EditServiceBean implements Serializable {
entity.setServiceProps(propertyMap);
entity.setGroupFilterRulePackage(selectedRulePackage);
entity.setMandatoryValueRulePackage(selectedMandatoryValuesRulePackage);
entity.setParentService(selectedParentService);
entity = service.save(entity);
return "show-service.xhtml?faces-redirect=true&id=" + entity.getId();
}
......@@ -297,4 +304,20 @@ public class EditServiceBean implements Serializable {
BusinessRulePackageEntity selectedMandatoryValuesRulePackage) {
this.selectedMandatoryValuesRulePackage = selectedMandatoryValuesRulePackage;
}
public List<ServiceEntity> getParentServiceList() {
return parentServiceList;
}
public void setParentServiceList(List<ServiceEntity> parentServiceList) {
this.parentServiceList = parentServiceList;
}
public ServiceEntity getSelectedParentService() {
return selectedParentService;
}
public void setSelectedParentService(ServiceEntity selectedParentService) {
this.selectedParentService = selectedParentService;
}
}
......@@ -38,6 +38,14 @@
<bw:inputText id="shortNameField" label="#{messages.short_name}"
value="#{editServiceBean.entity.shortName}" required="true"/>
<h:outputText value="#{messages.parent_service}:"/>
<h:selectOneMenu value="#{editServiceBean.selectedParentService}"
converter="#{serviceConverter}">
<f:selectItem itemLabel="Kein Parent Service" itemValue="#{null}"/>
<f:selectItems value="#{editServiceBean.parentServiceList}"
var="service" itemLabel="#{service.name} (id #{service.id})" itemValue="#{service}"/>
</h:selectOneMenu>
<h:outputText value="#{messages.approver_role}:"/>
<h:selectOneMenu value="#{editServiceBean.selectedApproverRole}"
converter="#{approverRoleConverter}">
......
......@@ -39,6 +39,12 @@
<h:outputText value="#{messages.short_name}:" />
<h:outputText value="#{showServiceBean.entity.shortName}" />
<h:outputText value="#{messages.parent_service}:" />
<h:outputText value="#{showServiceBean.entity.parentService.name}"
rendered="#{showServiceBean.entity.parentService != null}"/>
<h:outputText value="#{messages.no_parent_service}"
rendered="#{showServiceBean.entity.parentService == null}"/>
<h:outputText value="#{messages.approver_role}:" />
<h:outputText value="#{showServiceBean.entity.approverRole.name}"
rendered="#{showServiceBean.entity.approverRole != null}"/>
......@@ -72,6 +78,12 @@
<h:outputText value="#{messages.no_access_rule}"
rendered="#{showServiceBean.entity.accessRule == null}"/>
<h:outputText value="#{messages.mandatory_value_rule}:" />
<h:outputText value="#{showServiceBean.entity.mandatoryValueRulePackage.knowledgeBaseName}"
rendered="#{showServiceBean.entity.mandatoryValueRulePackage != null}"/>
<h:outputText value="#{messages.no_mandatory_value_rule}"
rendered="#{showServiceBean.entity.mandatoryValueRulePackage == null}"/>
<h:outputText value="#{messages.group_filter_rule}:" />
<h:outputText value="#{showServiceBean.entity.groupFilterRulePackage.knowledgeBaseName}"
rendered="#{showServiceBean.entity.groupFilterRulePackage != null}"/>
......
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