|
|
|
@ -7,12 +7,24 @@ import com.fr.intelli.record.Focus;
|
|
|
|
|
import com.fr.intelli.record.Original; |
|
|
|
|
import com.fr.plugin.file.submit.oss.conf.FileSubmitOssServerConfig; |
|
|
|
|
import com.fr.plugin.file.submit.oss.fun.OssConstants; |
|
|
|
|
import com.fr.plugin.file.submit.oss.fun.OssSubmitTarget; |
|
|
|
|
import com.fr.plugin.file.submit.oss.fun.OssSubmitTargetConfig; |
|
|
|
|
import com.fr.plugin.file.submit.oss.fun.OssUpload; |
|
|
|
|
import com.fr.plugin.file.submit.oss.fun.OssVariableValue; |
|
|
|
|
import com.fr.record.analyzer.EnableMetrics; |
|
|
|
|
import com.fr.report.worksheet.CalculatableResWorkSheet; |
|
|
|
|
import com.fr.script.Calculator; |
|
|
|
|
import com.fr.stable.ColumnRow; |
|
|
|
|
import com.fr.stable.ColumnRowRelated; |
|
|
|
|
import com.fr.stable.xml.XMLPrintWriter; |
|
|
|
|
import com.fr.stable.xml.XMLableReader; |
|
|
|
|
import com.fr.write.DBWriteAction; |
|
|
|
|
import com.fr.write.DMLReport; |
|
|
|
|
import com.fr.write.cal.WB; |
|
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 提交到OSS的任务 |
|
|
|
@ -39,12 +51,47 @@ public class OssSubmitJob extends AbstractSubmitTask {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Focus(id = "com.fr.plugin.file.submit.oss", text = "Plugin-File_Submit_OSS", source = Original.PLUGIN) |
|
|
|
|
public void doJob(Calculator calculator) throws Exception { |
|
|
|
|
public void doJob(Calculator ca) throws Exception { |
|
|
|
|
ossClient = new OSSClient( |
|
|
|
|
FileSubmitOssServerConfig.getInstance().getEndPoint(), |
|
|
|
|
FileSubmitOssServerConfig.getInstance().getAccessKeyId(), |
|
|
|
|
FileSubmitOssServerConfig.getInstance().getAccessKeySecret()); |
|
|
|
|
OssUpload.upload(calculator, ossClient, submitTargetConfig); |
|
|
|
|
CalculatableResWorkSheet currentReport = ca.getAttribute(DMLReport.KEY); |
|
|
|
|
if (submitTargetConfig != null && currentReport != null) { |
|
|
|
|
ColumnRow[] crs = calculateRelatedColumnRows(submitTargetConfig); |
|
|
|
|
if (currentReport instanceof WB) { |
|
|
|
|
WB wb = (WB) (currentReport); |
|
|
|
|
wb.setCurrentColumnRow(crs, (ColumnRow) ca.getAttribute(ColumnRow.class), ca, new DBWriteAction() { |
|
|
|
|
@Override |
|
|
|
|
public void run(int index, Calculator ca, int groupIdx) throws Exception { |
|
|
|
|
OssUpload.upload(ca, ossClient, submitTargetConfig); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean isDynamic() { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}, -1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private ColumnRow[] calculateRelatedColumnRows(OssSubmitTargetConfig config) { |
|
|
|
|
Set<ColumnRow> set = new HashSet<ColumnRow>(); |
|
|
|
|
OssSubmitTarget[] targets = config.getSubmitTargets(); |
|
|
|
|
for (OssSubmitTarget target : targets) { |
|
|
|
|
set.addAll(Arrays.asList(getColumnRowsFromValue(target.getDirectory()))); |
|
|
|
|
set.addAll(Arrays.asList(getColumnRowsFromValue(target.getName()))); |
|
|
|
|
set.addAll(Arrays.asList(getColumnRowsFromValue(target.getFile()))); |
|
|
|
|
} |
|
|
|
|
return set.toArray(new ColumnRow[0]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private ColumnRow[] getColumnRowsFromValue(OssVariableValue value) { |
|
|
|
|
if (value != null && value.getValue() instanceof ColumnRowRelated) { |
|
|
|
|
return ((ColumnRowRelated) value.getValue()).getRelatedColumnRows(); |
|
|
|
|
} |
|
|
|
|
return new ColumnRow[0]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|