You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.8 KiB
54 lines
1.8 KiB
package core.operation.utils;
|
|
|
|
import error.GExcptFormat;
|
|
import gdms.Configuration;
|
|
import gdms.Mode;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
public interface Utils {
|
|
Map<String,String> fileTableField = new HashMap<>() {
|
|
{
|
|
put("announcement","annex_url");
|
|
put("graduation_design_finished_product","graduation_design_url");
|
|
put("graduation_design_opening_report","report_url");
|
|
}};
|
|
static String stringOptionsFormat(String options){
|
|
return options.replaceAll(" {2,}", " ") ;
|
|
}
|
|
static Map<String, Object> string2MapOptions(String sOptions) throws GExcptFormat {
|
|
sOptions = stringOptionsFormat(sOptions);
|
|
Map<String, Object> options = new HashMap<>();
|
|
String[] sOpts = sOptions.split(" ");
|
|
for(int i=0;i<sOpts.length;i++){
|
|
if(Mode.strict==1){
|
|
if(sOpts[i].indexOf(0)=='-')
|
|
throw new GExcptFormat("options format error");
|
|
}
|
|
options.put(sOpts[i].substring(1),sOpts[++i]);
|
|
}
|
|
return options;
|
|
}
|
|
static String getFileField(String table){
|
|
return fileTableField.get(table);
|
|
}
|
|
static String getFilePath(String table){
|
|
return Configuration.filePath+table+"/";
|
|
}
|
|
static String getFileName(String fileName){
|
|
SimpleDateFormat simpleDateFormat;
|
|
simpleDateFormat = new SimpleDateFormat("yyMMddHHmmssSSS");
|
|
Date date = new Date();
|
|
String str = simpleDateFormat.format(date);
|
|
str+=(int)(Math.random()*100000);
|
|
str+= utils.Utils.getFileType(fileName);
|
|
return str;
|
|
}
|
|
static String getFilePathName(String table, String fileName){
|
|
return getFilePath(table)+getFileName(fileName);
|
|
}
|
|
}
|