@ -1,14 +1,7 @@
package io.sc.engine.rule.server.resource.controller ;
import io.sc.engine.rule.client.runtime.impl.groovy.GroovyScriptEngineService ;
import io.sc.engine.rule.client.runtime.impl.groovy.GroovyScriptEngineServiceImpl ;
import io.sc.engine.rule.client.spring.service.ExecutorFactoryService ;
import io.sc.engine.rule.core.ResourceAbstract ;
import io.sc.engine.rule.core.ResourceResult ;
import io.sc.engine.rule.core.code.ExecuteUnit ;
import io.sc.engine.rule.core.code.SourceCode ;
import io.sc.engine.rule.core.code.SourceCodeGenerator ;
import io.sc.engine.rule.core.code.generator.GroovySourceCodeGenerator ;
import io.sc.engine.rule.core.po.resource.Resource ;
import io.sc.engine.rule.server.common.plugins.PluginManager ;
import io.sc.engine.rule.server.common.plugins.item.ResourceExampleItem ;
@ -54,98 +47,108 @@ public class ResourceWebController extends RestCrudController<ResourceVo, Resour
return list ;
}
@GetMapping ( value = "getDefineById" )
@IgnoreResponseBodyAdvice
public ExecuteUnit getDefineById ( @RequestParam ( name = "id" , required = true ) String resourceId ) throws Exception {
ExecuteUnit wrapper = service . getDefineById ( resourceId ) ;
return wrapper ;
}
@GetMapping ( value = "getLastModifyDateById" )
@IgnoreResponseBodyAdvice
public Long getLastModifyDateById ( @RequestParam ( name = "id" , required = true ) String resourceId ) throws Exception {
return service . getLastModifyDateById ( resourceId ) ;
}
@GetMapping ( value = "getDefineById2" )
@IgnoreResponseBodyAdvice
public ExecuteUnit getDefineById2 ( @RequestParam ( name = "id" , required = true ) String resourceId ) throws Exception {
ExecuteUnit wrapper = service . getDefineById2 ( resourceId ) ;
return wrapper ;
}
@GetMapping ( value = "getDefineByCode" )
@IgnoreResponseBodyAdvice
public ExecuteUnit getDefineByCode ( @RequestParam ( name = "code" , required = true ) String resourceCode , @RequestParam ( name = "version" , required = false ) Integer version ) throws Exception {
ExecuteUnit wrapper = service . getDefineByCode ( resourceCode , version ) ;
return wrapper ;
}
@GetMapping ( value = "getLastModifyDateByCode" )
@IgnoreResponseBodyAdvice
public Long getLastModifyDateByCode ( @RequestParam ( name = "code" , required = true ) String resourceCode , @RequestParam ( name = "version" , required = false ) Integer version ) throws Exception {
return service . getLastModifyDateByCode ( resourceCode , version ) ;
}
@PostMapping ( value = "executeById" )
@IgnoreResponseBodyAdvice
public ResourceResult executeById (
@RequestParam ( name = "resourceId" ) String resourceId ,
@RequestParam ( name = "subModelCode" , required = false ) String subModelCode ,
@RequestBody String json
) throws Exception {
if ( StringUtils . hasText ( subModelCode ) ) {
return executorFactoryService . getExecutor ( ) . executeById ( resourceId , subModelCode , json ) ;
} else {
return executorFactoryService . getExecutor ( ) . executeById ( resourceId , json ) ;
}
}
@PostMapping ( value = "executeByCode" )
@IgnoreResponseBodyAdvice
public ResourceResult executeByCode (
@RequestParam ( name = "resourceCode" ) String resourceCode ,
@RequestParam ( name = "version" , required = false ) Integer version ,
@RequestParam ( name = "subModelCode" , required = false ) String subModelCode ,
@RequestBody String json
) throws Exception {
if ( StringUtils . hasText ( subModelCode ) ) {
return executorFactoryService . getExecutor ( ) . executeByCode ( resourceCode , version , subModelCode , json ) ;
} else {
return executorFactoryService . getExecutor ( ) . executeByCode ( resourceCode , version , json ) ;
}
}
@PostMapping ( value = "generateGroovySourceCode/{resourceId}" )
public SourceCode generateGroovySourceCode ( @PathVariable ( name = "resourceId" , required = true ) String resourceId ) throws Exception {
ExecuteUnit wrapper = getDefineById ( resourceId ) ;
SourceCodeGenerator generator = new GroovySourceCodeGenerator ( ) ;
return generator . generate ( null , wrapper ) ;
}
@PostMapping ( value = "generateGroovySourceCodeForTest/{resourceId}" )
public SourceCode generateGroovySourceCodeForTest ( @PathVariable ( name = "resourceId" , required = true ) String resourceId ) throws Exception {
ExecuteUnit wrapper = getDefineById ( resourceId ) ;
SourceCodeGenerator generator = new GroovySourceCodeGenerator ( ) ;
return generator . generate ( null , wrapper ) ;
}
@PostMapping ( value = "sourceCodeValidate/{resourceId}" )
public void sourceCodeValidate ( @PathVariable ( name = "resourceId" , required = true ) String resourceId ) throws Exception {
ExecuteUnit wrapper = getDefineById ( resourceId ) ;
SourceCodeGenerator generator = new GroovySourceCodeGenerator ( ) ;
SourceCode sourceCode = generator . generate ( resourceId , wrapper ) ;
GroovyScriptEngineService engineService = new GroovyScriptEngineServiceImpl ( ) ;
engineService . validate ( sourceCode . getSource ( ) ) ;
// @GetMapping(value="getDefineById")
// @IgnoreResponseBodyAdvice
// public ExecuteUnit getDefineById(@RequestParam(name="id",required=true)String resourceId) throws Exception{
// ExecuteUnit wrapper =service.getDefineById(resourceId);
// return wrapper;
// }
//
// @GetMapping(value="getLastModifyDateById")
// @IgnoreResponseBodyAdvice
// public Long getLastModifyDateById(@RequestParam(name="id",required=true)String resourceId) throws Exception{
// return service.getLastModifyDateById(resourceId);
// }
//
// @GetMapping(value="getDefineById2")
// @IgnoreResponseBodyAdvice
// public ExecuteUnit getDefineById2(@RequestParam(name="id",required=true)String resourceId) throws Exception{
// ExecuteUnit wrapper =service.getDefineById2(resourceId);
// return wrapper;
// }
//
// @GetMapping(value="getDefineByCode")
// @IgnoreResponseBodyAdvice
// public ExecuteUnit getDefineByCode(@RequestParam(name="code",required=true)String resourceCode,@RequestParam(name="version",required=false)Integer version) throws Exception{
// ExecuteUnit wrapper =service.getDefineByCode(resourceCode, version);
// return wrapper;
// }
//
// @GetMapping(value="getLastModifyDateByCode")
// @IgnoreResponseBodyAdvice
// public Long getLastModifyDateByCode(@RequestParam(name="code",required=true)String resourceCode,@RequestParam(name="version",required=false)Integer version) throws Exception{
// return service.getLastModifyDateByCode(resourceCode,version);
// }
//
// @PostMapping(value="executeById")
// @IgnoreResponseBodyAdvice
// public ResourceResult executeById(
// @RequestParam(name="resourceId") String resourceId,
// @RequestParam(name="subModelCode",required=false) String subModelCode,
// @RequestBody String json
// ) throws Exception{
// if(StringUtils.hasText(subModelCode)) {
// return executorFactoryService.getExecutor().executeById(resourceId, subModelCode, json);
// }else {
// return executorFactoryService.getExecutor().executeById(resourceId, json);
// }
// }
//
// @PostMapping(value="executeByCode")
// @IgnoreResponseBodyAdvice
// public ResourceResult executeByCode(
// @RequestParam(name="resourceCode") String resourceCode,
// @RequestParam(name="version",required=false) Integer version,
// @RequestParam(name="subModelCode",required=false) String subModelCode,
// @RequestBody String json
// ) throws Exception{
// if(StringUtils.hasText(subModelCode)) {
// return executorFactoryService.getExecutor().executeByCode(resourceCode, version, subModelCode, json);
// }else {
// return executorFactoryService.getExecutor().executeByCode(resourceCode, version, json);
// }
// }
//
// @PostMapping(value="generateGroovySourceCode/{resourceId}")
// public SourceCode generateGroovySourceCode(@PathVariable(name="resourceId",required=true)String resourceId) throws Exception{
// ExecuteUnit wrapper =getDefineById(resourceId);
// SourceCodeGenerator generator =new GroovySourceCodeGenerator();
// return generator.generate(null,wrapper);
// }
//
// @PostMapping(value="generateGroovySourceCodeForTest/{resourceId}")
// public SourceCode generateGroovySourceCodeForTest(@PathVariable(name="resourceId",required=true)String resourceId) throws Exception{
// ExecuteUnit wrapper =getDefineById(resourceId);
// SourceCodeGenerator generator =new GroovySourceCodeGenerator();
// return generator.generate(null,wrapper);
// }
//
// @PostMapping(value="sourceCodeValidate/{resourceId}")
// public void sourceCodeValidate(@PathVariable(name="resourceId",required=true)String resourceId) throws Exception{
// ExecuteUnit wrapper =getDefineById(resourceId);
// SourceCodeGenerator generator =new GroovySourceCodeGenerator();
// SourceCode sourceCode =generator.generate(resourceId,wrapper);
// GroovyScriptEngineService engineService =new GroovyScriptEngineServiceImpl();
// engineService.validate(sourceCode.getSource());
// }
//
// @PostMapping(value="sourceCodeValidateForTest/{resourceId}")
// public void sourceCodeValidateForTest(@PathVariable(name="resourceId",required=true)String resourceId) throws Exception{
// ExecuteUnit wrapper =getDefineById(resourceId);
// SourceCodeGenerator generator =new GroovySourceCodeGenerator();
// SourceCode sourceCode =generator.generate(resourceId,wrapper);
// GroovyScriptEngineService engineService =new GroovyScriptEngineServiceImpl();
// engineService.validate(sourceCode.getSource());
// }
//
@PostMapping ( value = "preDeploy/{resourceId}" )
public List < ResourceVo > preDeploy ( @PathVariable ( name = "resourceId" , required = true ) String resourceId ) throws Exception {
return service . preDeploy ( resourceId ) ;
}
@PostMapping ( value = "sourceCodeValidateForTest/{resourceId}" )
public void sourceCodeValidateForTest ( @PathVariable ( name = "resourceId" , required = true ) String resourceId ) throws Exception {
ExecuteUnit wrapper = getDefineById ( resourceId ) ;
SourceCodeGenerator generator = new GroovySourceCodeGenerator ( ) ;
SourceCode sourceCode = generator . generate ( resourceId , wrapper ) ;
GroovyScriptEngineService engineService = new GroovyScriptEngineServiceImpl ( ) ;
engineService . validate ( sourceCode . getSource ( ) ) ;
@PostMapping ( value = "cancelPreDeploy/{resourceId}" )
public List < ResourceVo > cancelPreDeploy ( @PathVariable ( name = "resourceId" , required = true ) String resourceId ) throws Exception {
return service . cancelPreDeploy ( resourceId ) ;
}
/ * *