Commit 7fda99bc authored by Malo Toudic's avatar Malo Toudic
Browse files
parent 13318ab6
......@@ -158,5 +158,11 @@
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>apache-log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
</dependencies>
</project>
package net.ihe.gazelle.wstester.action;
import net.ihe.gazelle.common.filter.Filter;
import net.ihe.gazelle.common.filter.list.GazelleListDataModel;
import net.ihe.gazelle.wstester.dao.SoapuiProjectDao;
import net.ihe.gazelle.common.filter.FilterDataModel;
import net.ihe.gazelle.hql.criterion.HQLCriterionsForFilter;
import net.ihe.gazelle.wstester.model.SoapuiProject;
import net.ihe.gazelle.wstester.model.SoapuiProjectQuery;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import javax.faces.context.FacesContext;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
@Name("projectList")
@Scope(ScopeType.PAGE)
public class ProjectList implements Serializable {
private List<SoapuiProject> soapuiProjects;
private FilterDataModel<SoapuiProject> soapuiProjects;
private Filter<SoapuiProject> filter;
public GazelleListDataModel<SoapuiProject> getSoapuiProjects() {
return new GazelleListDataModel<SoapuiProject>(soapuiProjects);
public FilterDataModel<SoapuiProject> getSoapuiProjects() {
return new FilterDataModel<SoapuiProject>(getFilter()) {
@Override
protected Object getId(SoapuiProject soapuiProject) {
return soapuiProject.getId();
}
};
}
public void setSoapuiProjects(List<SoapuiProject> soapuiProject) {
this.soapuiProjects = soapuiProject;
public Filter<SoapuiProject> getFilter() {
if (filter == null) {
Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
this.filter = new Filter(this.getHqlCriterions(), params);
}
return this.filter;
}
@Create
public void init() {
this.soapuiProjects = SoapuiProjectDao.getAllSoapuiProject();
private HQLCriterionsForFilter getHqlCriterions() {
SoapuiProjectQuery query = new SoapuiProjectQuery();
HQLCriterionsForFilter criterion = query.getHQLCriterionsForFilter();
criterion.addPath("label", query.label());
criterion.addPath("owner", query.owner());
criterion.addPath("creationDate", query.creationDate());
criterion.addPath("active", query.active());
return criterion;
}
public void reset() {
if (this.filter != null) {
this.filter.clear();
}
}
}
\ No newline at end of file
package net.ihe.gazelle.wstester.action;
import net.ihe.gazelle.wstester.dao.SoapuiProjectDao;
import net.ihe.gazelle.wstester.model.SoapuiProject;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import javax.faces.event.AjaxBehaviorEvent;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Name("run")
@Scope(ScopeType.PAGE)
public class Run implements Serializable {
private List<SoapuiProject> soapuiProjects;
private SoapuiProject currentProject;
public List<SoapuiProject> getSoapuiProjects() {
return soapuiProjects;
}
public void setSoapuiProjects(List<SoapuiProject> soapuiProjects) {
this.soapuiProjects = soapuiProjects;
}
public List<String> getSoapuiProjectsLabel() {
List<String> listLabel = new ArrayList<>();
for (SoapuiProject project : soapuiProjects) {
listLabel.add(project.getLabel());
}
return listLabel;
}
public void selectProject(AjaxBehaviorEvent event) {
currentProject = event.getComponent()
}
@Create
public void init() {
setSoapuiProjects(SoapuiProjectDao.getAllSoapuiProject());
}
}
......@@ -19,6 +19,8 @@ import org.apache.xmlbeans.XmlException;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.international.StatusMessage;
import org.jboss.seam.security.Identity;
import org.richfaces.event.FileUploadEvent;
import org.richfaces.model.UploadedFile;
......@@ -179,13 +181,17 @@ public class UploadProject implements Serializable {
Files.move(Paths.get(soapuiProject.getXmlFilePath()), Paths.get(target));
soapuiProject.setXmlFilePath(target);
} catch (IOException e) {
e.printStackTrace();
// e.printStackTrace();
LOGGER.error(e.getMessage());
}
soapuiProject = SoapuiProjectDao.mergeSoapuiProject(soapuiProject);
}
private boolean checkLabelInDb() {
if (SoapuiProjectDao.getListSoapuiProjectByLabel(this.soapuiProject.getLabel()) != null) {
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "There is already a SoapUI project with the same label : " + soapuiProject
.getLabel());
return false;
}
return true;
......
......@@ -3,6 +3,8 @@ package net.ihe.gazelle.wstester.dao;
import net.ihe.gazelle.hql.providers.EntityManagerService;
import net.ihe.gazelle.wstester.model.SoapuiProject;
import net.ihe.gazelle.wstester.model.SoapuiProjectQuery;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.international.StatusMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -19,16 +21,19 @@ public class SoapuiProjectDao {
public static SoapuiProject mergeSoapuiProject(SoapuiProject soapuiProject) {
if (soapuiProject.getXmlFilePath() == null || soapuiProject.getXmlFilePath().isEmpty()) {
SoapuiProjectDao.LOGGER.error("Cannot merge the given SoapuiProject because XmlFilePath is null");
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "The path of the SoapUI Project is empty");
return null;
} else {
final File uploadedFile = new File(soapuiProject.getXmlFilePath());
if (!uploadedFile.exists()) {
SoapuiProjectDao.LOGGER.error("The given file does not exist: {}", soapuiProject.getXmlFilePath());
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "The SoapUI Project file does not exist");
return null;
}
final EntityManager em = EntityManagerService.provideEntityManager();
SoapuiProject newSoapuiProject = em.merge(soapuiProject);
em.flush();
FacesMessages.instance().add(StatusMessage.Severity.INFO, "Success to save soap ui project");
return newSoapuiProject;
}
}
......
......@@ -12,4 +12,9 @@
<h:outputText value="Project List"/>
</h:outputLink>
</li>
<li>
<h:outputLink value="/gazelle-webservice-tester/run.seam">
<h:outputText value="Run"/>
</h:outputLink>
</li>
</ui:composition>
\ No newline at end of file
<ui:composition xmlns:h="http://java.sun.com/jsf/html" xmlns:s="http://jboss.org/schema/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:rich="http://richfaces.org/rich"
xmlns:g="http://www.ihe.net/gazelle" xmlns="http://www.w3.org/1999/xhtml"
xmlns:a4j="http://richfaces.org/a4j"
template="/layout/template.xhtml">
<ui:param name="pageNameTitle" value="SoapUI project detail"/>
<ui:param name="pageNameTitle" value="List of SoapUI project"/>
<ui:define name="body">
<h:form id="globalForm">
<ui:decorate template="/layout/panels/_panel_filter_criteria.xhtml">
<ui:define name="panel_title">#{messages['gazelle.simu.SearchCriteria']}</ui:define>
<div class="row">
<div class="col-md-6">
<ui:include src="/filter/filter.xhtml">
<ui:param name="filter" value="#{projectList.filter}"/>
<ui:param name="filterId" value="owner"/>
<ui:param name="filterName" value="Owner"/>
<ui:param name="filterForm" value="globalForm"/>
</ui:include>
</div>
<div class="col-md-6">
<ui:include src="/filter/filter.xhtml">
<ui:param name="filter" value="#{projectList.filter}"/>
<ui:param name="filterId" value="label"/>
<ui:param name="filterName" value="Label"/>
<ui:param name="filterForm" value="globalForm"/>
</ui:include>
</div>
</div>
<div class="row">
<div class="col-md-6">
<ui:include src="/filter/filterDate.xhtml">
<ui:param name="filter" value="#{projectList.filter}"/>
<ui:param name="filterId" value="creationDate"/>
<ui:param name="filterName" value="Creation Date"/>
<ui:param name="filterForm" value="globalForm"/>
</ui:include>
</div>
<div class="col-md-6">
<ui:include src="/filter/filter.xhtml">
<ui:param name="filter" value="#{projectList.filter}"/>
<ui:param name="filterId" value="active"/>
<ui:param name="filterName" value="Active"/>
<ui:param name="filterForm" value="globalForm"/>
</ui:include>
</div>
</div>
<ui:define name="filter_buttons">
<a4j:commandLink title="Refresh results"
render="globalForm">
<span class="gzl-icon-refresh"/>
</a4j:commandLink>
<a4j:commandLink title="Reset"
actionListener="#{projectList.reset()}"
render="globalForm">
<span class="fa fa-times-circle"></span>
</a4j:commandLink>
</ui:define>
</ui:decorate>
<s:div id="resultDiv">
<rich:dataTable value="#{projectList.soapuiProjects}" var="project" styleClass="table table-striped table-responsive">
<rich:dataTable value="#{projectList.soapuiProjects()}" var="project" styleClass="table table-striped table-responsive">
<g:column sortBy="#{'id'}">
<ui:define name="header">Id</ui:define>
......
<ui:composition xmlns:h="http://java.sun.com/jsf/html" xmlns:s="http://jboss.org/schema/seam/taglib"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:gri="http://java.sun.com/jsf/composite/gri" xmlns="http://www.w3.org/1999/xhtml"
template="//layout/template.xhtml">
<ui:param name="pageNameTitle" value="Run a SaopUI project"/>
<ui:define name="body">
<h:form>
<s:div id="globalDiv">
<gri:panel>
<f:facet name="header">
<h:outputText value="Project"/>
</f:facet>
<h:selectOneMenu styleClass="form-control gzl-select-text" value="Test">
<f:selectItems value="#{run.getSoapuiProjectsLabel()}"/>
<f:ajax listener="#{run.selectProject}"/>
</h:selectOneMenu>
<f:facet name="footer">
<h:outputText value="Panel footer"/>
</f:facet>
</gri:panel>
</s:div>
</h:form>
</ui:define>
</ui:composition>
\ No newline at end of file
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