Merge branch 'master' of https://github.com/lostcharlie/Bench4Q
This commit is contained in:
commit
532700d0af
|
@ -1,29 +1,25 @@
|
|||
publish tar.gz false lib false false runtime target/bench4q-master.jar /
|
||||
This XML file does not appear to have any style information associated with it. The document tree is shown below.
|
||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>publish</id>
|
||||
<formats>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
<formats>...</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<useProjectArtifact>false</useProjectArtifact>
|
||||
<unpack>false</unpack>
|
||||
<scope>runtime</scope>
|
||||
</dependencySet>
|
||||
<dependencySet>...</dependencySet>
|
||||
</dependencySets>
|
||||
<dependencySets>...</dependencySets>
|
||||
<files>
|
||||
<file>
|
||||
<source>target/bench4q-master.jar</source>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</file>
|
||||
<file>...</file>
|
||||
</files>
|
||||
<files>...</files>
|
||||
</assembly>
|
||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">...</assembly>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>publish</id>
|
||||
<formats>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<useProjectArtifact>false</useProjectArtifact>
|
||||
<unpack>false</unpack>
|
||||
<scope>runtime</scope>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
<files>
|
||||
<file>
|
||||
<source>target/bench4q-master.jar</source>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
|
@ -2,6 +2,7 @@ package org.bench4q.master.domain.factory;
|
|||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.domain.entity.plugin.Method;
|
||||
import org.bench4q.master.domain.entity.plugin.MethodParam;
|
||||
import org.bench4q.master.domain.entity.plugin.MethodParamProperty;
|
||||
|
@ -16,6 +17,7 @@ import org.bench4q.share.models.master.plugin.ParamTypeEnum;
|
|||
import org.bench4q.share.models.master.plugin.PluginModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class PluginFactory {
|
||||
|
||||
|
@ -30,7 +32,8 @@ public class PluginFactory {
|
|||
this.pluginRepository = pluginRepository;
|
||||
}
|
||||
|
||||
public Plugin createPluginEntity(PluginModel pluginModel) throws Bench4QException {
|
||||
public Plugin createPluginEntity(PluginModel pluginModel)
|
||||
throws Bench4QException {
|
||||
Plugin plugin = new Plugin();
|
||||
plugin.setPluginMethods(new HashSet<Method>());
|
||||
if (pluginModel.getMethods() != null) {
|
||||
|
@ -45,13 +48,15 @@ public class PluginFactory {
|
|||
|
||||
}
|
||||
|
||||
private Method createMethodEntity(MethodModel methodModel, Plugin plugin) throws Bench4QException {
|
||||
private Method createMethodEntity(MethodModel methodModel, Plugin plugin)
|
||||
throws Bench4QException {
|
||||
Method method = new Method();
|
||||
method.setMethodParams(new HashSet<MethodParam>());
|
||||
method.setName(methodModel.getName());
|
||||
if (methodModel.getMethodParams() != null) {
|
||||
for (MethodParamModel methodParamModel : methodModel
|
||||
.getMethodParams()) {
|
||||
Logger.getLogger(PluginFactory.class).info("method model:" + methodModel.getName());
|
||||
method.getMethodParams().add(
|
||||
createMethodParamEntity(methodParamModel, method));
|
||||
}
|
||||
|
@ -62,7 +67,8 @@ public class PluginFactory {
|
|||
}
|
||||
|
||||
private MethodParam createMethodParamEntity(
|
||||
MethodParamModel methodParamModel, Method method) throws Bench4QException {
|
||||
MethodParamModel methodParamModel, Method method)
|
||||
throws Bench4QException {
|
||||
MethodParam methodParam = new MethodParam();
|
||||
methodParam.setLable(methodParamModel.getLable());
|
||||
methodParam.setName(methodParamModel.getName());
|
||||
|
@ -82,7 +88,8 @@ public class PluginFactory {
|
|||
return methodParam;
|
||||
}
|
||||
|
||||
private ParamType createPraParamTypeWithOutId(ParamTypeEnum paramTypeEnum) throws Bench4QException {
|
||||
private ParamType createPraParamTypeWithOutId(ParamTypeEnum paramTypeEnum)
|
||||
throws Bench4QException {
|
||||
return this.getPluginRepository().getParamTypeByType(paramTypeEnum);
|
||||
}
|
||||
|
||||
|
@ -91,7 +98,8 @@ public class PluginFactory {
|
|||
MethodParam methodParam) {
|
||||
MethodParamProperty methodParamProperty = new MethodParamProperty();
|
||||
methodParamProperty.setPropertyKey(methodParamPropertyModel.getKey());
|
||||
methodParamProperty.setPropertyValue(methodParamPropertyModel.getValue());
|
||||
methodParamProperty.setPropertyValue(methodParamPropertyModel
|
||||
.getValue());
|
||||
methodParamProperty.setMethodParam(methodParam);
|
||||
return methodParamProperty;
|
||||
}
|
||||
|
@ -131,7 +139,8 @@ public class PluginFactory {
|
|||
MethodParamProperty methodParamProperty) {
|
||||
MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel();
|
||||
methodParamPropertyModel.setKey(methodParamProperty.getPropertyKey());
|
||||
methodParamPropertyModel.setValue(methodParamProperty.getPropertyValue());
|
||||
methodParamPropertyModel.setValue(methodParamProperty
|
||||
.getPropertyValue());
|
||||
return methodParamPropertyModel;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,38 +15,41 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
@Component
|
||||
public class PluginRepository extends AbstractRepositoty {
|
||||
private boolean fillParamType() throws Bench4QException{
|
||||
Session session = this.getSessionHelper().openSession();
|
||||
@SuppressWarnings("unchecked")
|
||||
private void fillParamType(Session session) throws Bench4QException {
|
||||
|
||||
Transaction transaction = session.beginTransaction();
|
||||
try {
|
||||
for(ParamTypeEnum paramTypeEnum :ParamTypeEnum.values()){
|
||||
ParamType paramType=new ParamType();
|
||||
paramType.setType(paramTypeEnum);
|
||||
session.merge(paramType);
|
||||
List<ParamType> ret = session.createCriteria(ParamType.class).list();
|
||||
if (ret.size() == 0) {
|
||||
try {
|
||||
for (ParamTypeEnum paramTypeEnum : ParamTypeEnum.values()) {
|
||||
ParamType paramType = new ParamType();
|
||||
paramType.setType(paramTypeEnum);
|
||||
session.merge(paramType);
|
||||
}
|
||||
transaction.commit();
|
||||
} catch (Exception e) {
|
||||
transaction.rollback();
|
||||
logger.error(e, e.fillInStackTrace());
|
||||
throw new Bench4QException("", "fill paramType fail", "");
|
||||
}
|
||||
|
||||
transaction.commit();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
transaction.rollback();
|
||||
logger.error(e, e.fillInStackTrace());
|
||||
throw new Bench4QException("", "fill paramType fail", "");
|
||||
} finally {
|
||||
releaseSession(session);
|
||||
}
|
||||
}
|
||||
public ParamType getParamTypeByType(ParamTypeEnum paramTypeEnum) throws Bench4QException {
|
||||
|
||||
|
||||
public ParamType getParamTypeByType(ParamTypeEnum paramTypeEnum)
|
||||
throws Bench4QException {
|
||||
|
||||
ParamType paramType = null;
|
||||
Session session = this.getSessionHelper().openSession();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<ParamType> ret = session.createCriteria(ParamType.class)
|
||||
.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
|
||||
if(ret.size()==0){
|
||||
fillParamType();
|
||||
List<ParamType> ret = session.createCriteria(ParamType.class).list();
|
||||
if (ret.size() == 0) {
|
||||
fillParamType(session);
|
||||
}
|
||||
paramType = (ParamType) session.createCriteria(ParamType.class)
|
||||
.add(Restrictions.eq("type", paramTypeEnum)).uniqueResult();
|
||||
if (paramType == null)
|
||||
logger.info("paramType not exit");
|
||||
releaseSession(session);
|
||||
return paramType;
|
||||
}
|
||||
|
@ -81,10 +84,10 @@ public class PluginRepository extends AbstractRepositoty {
|
|||
protected void guardOtherUniqueConditionForEntity(
|
||||
String uniquePropertyName, String value)
|
||||
throws EntityUniqueAlReadyExistException {
|
||||
/*if (getPlugin(value) != null) {
|
||||
if (getPlugin(value) != null) {
|
||||
throw new EntityUniqueAlReadyExistException("User with the name "
|
||||
+ value + "already exists");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
public boolean detach(String pluginName) throws Bench4QException {
|
||||
|
|
Loading…
Reference in New Issue