|
@@ -9,11 +9,13 @@ import io.renren.common.utils.R;
|
|
|
import io.renren.common.validator.ValidatorUtils;
|
|
|
import io.renren.common.validator.group.AddGroup;
|
|
|
import io.renren.common.validator.group.UpdateGroup;
|
|
|
+import io.renren.modules.dataSet.enumeration.DataSetType;
|
|
|
import io.renren.modules.sys.entity.algs.*;
|
|
|
import io.renren.modules.sys.entity.dataset.DataSet;
|
|
|
import io.renren.modules.sys.service.*;
|
|
|
import io.renren.modules.sys.service.impl.AlgsModelsServiceImpl;
|
|
|
import io.renren.modules.sys.service.impl.AlgsServiceImpl;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -107,10 +109,13 @@ public class algsController{
|
|
|
alg.setNumber(Long.parseLong(request.getParameter("number")));
|
|
|
|
|
|
ValidatorUtils.validateEntity(alg, AddGroup.class);
|
|
|
- List<Algorithm> list = algsService.list();
|
|
|
- for(Algorithm algorithm : list){
|
|
|
- if(algorithm.getAlgorithmName().equals(alg.getAlgorithmName())) return R.error("已经存在重复名称的算法");
|
|
|
+ if (algsService.selectByAlgName(alg.getAlgorithmName()) != null) {
|
|
|
+ return R.error("已经存在重复名称的算法");
|
|
|
}
|
|
|
+ // List<Algorithm> list = algsService.list();
|
|
|
+ // for(Algorithm algorithm : list){
|
|
|
+ // if(algorithm.getAlgorithmName().equals(alg.getAlgorithmName())) return R.error("已经存在重复名称的算法");
|
|
|
+ // }
|
|
|
// user.setCreateUserId(getUserId());
|
|
|
|
|
|
algsService.save(alg);
|
|
@@ -193,54 +198,73 @@ public class algsController{
|
|
|
* @param files 算法文件
|
|
|
*/
|
|
|
public void saveTraditionalAlg(Algorithm alg,List<MultipartFile> files,String algParameterNameString,String algParameterTypeString,String algResultNameString,String algResultLocationString,String dataSetsString) throws IOException, InvalidKeyException, NoSuchAlgorithmException, InsufficientDataException, InvalidResponseException, ErrorResponseException, XmlParserException, InvalidBucketNameException, InternalException {
|
|
|
- Long algId=alg.getAlgorithmId();
|
|
|
+ Long algId = alg.getAlgorithmId();
|
|
|
|
|
|
- System.out.println("算法参数名是");
|
|
|
- String[] algorithmParameterNames=algParameterNameString.split(",");
|
|
|
- for(String s:algorithmParameterNames){
|
|
|
- System.out.println(s);
|
|
|
+ String[] algorithmParameterNames = new String[0];
|
|
|
+ if (StringUtils.isNotEmpty(algParameterNameString)) {
|
|
|
+ algorithmParameterNames=algParameterNameString.split(",");
|
|
|
}
|
|
|
|
|
|
- System.out.println("算法参数类别是");
|
|
|
- String[] algorithmParameterTypes=algParameterTypeString.split(",");
|
|
|
- for(String s:algorithmParameterTypes){
|
|
|
- System.out.println(s);
|
|
|
+ // System.out.println("算法参数名是");
|
|
|
+ // String[] algorithmParameterNames=algParameterNameString.split(",");
|
|
|
+ // for(String s:algorithmParameterNames){
|
|
|
+ // System.out.println(s);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // System.out.println("算法参数类别是");
|
|
|
+ // String[] algorithmParameterTypes=algParameterTypeString.split(",");
|
|
|
+ // for(String s:algorithmParameterTypes){
|
|
|
+ // System.out.println(s);
|
|
|
+ // }
|
|
|
+
|
|
|
+ String[] algorithmParameterTypes = new String[0];
|
|
|
+ if (StringUtils.isNotEmpty(algParameterTypeString)) {
|
|
|
+ algorithmParameterTypes = algParameterTypeString.split(",");
|
|
|
}
|
|
|
- for(int i=0;i<algorithmParameterNames.length;i++){
|
|
|
- AlgorithmParameter algorithmParameter=new AlgorithmParameter();
|
|
|
+ for (int i = 0; i < algorithmParameterNames.length; i++) {
|
|
|
+ AlgorithmParameter algorithmParameter = new AlgorithmParameter();
|
|
|
algorithmParameter.setAlgorithmId(algId);
|
|
|
algorithmParameter.setAlgorithmParameterName(algorithmParameterNames[i]);
|
|
|
algorithmParameter.setAlgorithmParameterType(algorithmParameterTypes[i]);
|
|
|
algorithmParameterService.save(algorithmParameter);
|
|
|
}
|
|
|
|
|
|
- System.out.println("算法结果名是");
|
|
|
- String[] algorithmResultNames=algResultNameString.split(",");
|
|
|
- for(String s:algorithmResultNames){
|
|
|
- System.out.println(s);
|
|
|
+ String[] algorithmResultNames = new String[0];
|
|
|
+ if (StringUtils.isNotEmpty(algResultNameString)) {
|
|
|
+ algorithmResultNames = algResultNameString.split(",");
|
|
|
}
|
|
|
- System.out.println("算法结果文件位置是");
|
|
|
- String[] algorithmResultLocations=algResultLocationString.split(",");
|
|
|
- for(String s:algorithmResultLocations){
|
|
|
- System.out.println(s);
|
|
|
+ // System.out.println("算法结果名是");
|
|
|
+ // String[] algorithmResultNames=algResultNameString.split(",");
|
|
|
+ // for(String s:algorithmResultNames){
|
|
|
+ // System.out.println(s);
|
|
|
+ // }
|
|
|
+
|
|
|
+ String[] algorithmResultLocations = new String[0];
|
|
|
+ if (StringUtils.isNotEmpty(algResultLocationString)) {
|
|
|
+ algorithmResultLocations = algResultLocationString.split(",");
|
|
|
}
|
|
|
- for(int i=0;i<algorithmResultNames.length;i++){
|
|
|
- AlgorithmResult algorithmResult=new AlgorithmResult();
|
|
|
+ // System.out.println("算法结果文件位置是");
|
|
|
+ // String[] algorithmResultLocations=algResultLocationString.split(",");
|
|
|
+ // for(String s:algorithmResultLocations){
|
|
|
+ // System.out.println(s);
|
|
|
+ // }
|
|
|
+ for(int i = 0; i < algorithmResultNames.length; i++){
|
|
|
+ AlgorithmResult algorithmResult = new AlgorithmResult();
|
|
|
algorithmResult.setAlgorithmId(algId);
|
|
|
algorithmResult.setAlgorithmResultName(algorithmResultNames[i]);
|
|
|
algorithmResult.setAlgorithmResultLocation(algorithmResultLocations[i]);
|
|
|
algorithmResultService.save(algorithmResult);
|
|
|
}
|
|
|
//将算法文件上传
|
|
|
- for(MultipartFile file:files){
|
|
|
+ for (MultipartFile file : files) {
|
|
|
if(file.isEmpty()) break;
|
|
|
MinIoUtils.uploadMultipartFile(file,"algorithm","alg"+algId+"/"+file.getOriginalFilename());
|
|
|
}
|
|
|
//将数据集上传
|
|
|
- if(dataSetsString.length()!=0){
|
|
|
- String[] dataSets=dataSetsString.split(",");
|
|
|
- for(String fileName:dataSets){
|
|
|
- MinIoUtils.copyFile("algorithm","alg"+algId+"/"+fileName,"dataset",fileName);
|
|
|
+ if (StringUtils.isNotEmpty(dataSetsString)){
|
|
|
+ String[] dataSets = dataSetsString.split(",");
|
|
|
+ for (String fileName : dataSets) {
|
|
|
+ MinIoUtils.copyFile("algorithm","alg"+algId+"/"+fileName, DataSetType.STATIC_DATASET.getBucketName(), fileName);
|
|
|
}
|
|
|
}
|
|
|
}
|