xml-importer minor code changes
This commit is contained in:
parent
491577b6f8
commit
7a157e9ae2
6 changed files with 156 additions and 17 deletions
17
clearing-parent/xml-exporter/.idea/dataSources.xml
generated
Normal file
17
clearing-parent/xml-exporter/.idea/dataSources.xml
generated
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="clearing@localhost" uuid="8f6a6996-0d81-423c-b506-8dd4667b4c00">
|
||||
<driver-ref>postgresql</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:postgresql://localhost:5433/clearing</jdbc-url>
|
||||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
package ru.spcex.clearing.xml.exporter.exceptions;
|
||||
|
||||
public class ConfigException extends RuntimeException {
|
||||
public ConfigException(String msg) { super(msg); }
|
||||
public ConfigException(String msg, Throwable cause) { super(msg, cause); }
|
||||
}
|
||||
124
clearing-parent/xml-importer/.idea/uiDesigner.xml
generated
Normal file
124
clearing-parent/xml-importer/.idea/uiDesigner.xml
generated
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -26,6 +26,7 @@ public class ChangeDirOfFileStage {
|
|||
}
|
||||
|
||||
public StageResult process(ResultContainer resultContainer) {
|
||||
log.info("uuid {}. Stage: Change directory of file", resultContainer.getUuid());
|
||||
File srcDir = new File(settings.getStore().getSrcDir());
|
||||
File outDir;
|
||||
if (resultContainer.getLastStageStatus().equals(StageResult.ERROR)) {
|
||||
|
|
@ -38,6 +39,7 @@ public class ChangeDirOfFileStage {
|
|||
|
||||
if (!srcDir.exists()) {
|
||||
log.error("SettlementHouse_DocIn does not exists!");
|
||||
notifyWithCode(resultContainer, StageResult.ERROR);
|
||||
return StageResult.ERROR;
|
||||
}
|
||||
if (!outDir.exists()) {
|
||||
|
|
@ -46,11 +48,13 @@ public class ChangeDirOfFileStage {
|
|||
log.error("Made dir {} successfully!", outDir.getName());
|
||||
} else {
|
||||
log.error("SettlementHouse_DocIn does not exists!");
|
||||
notifyWithCode(resultContainer, StageResult.ERROR);
|
||||
return StageResult.ERROR;
|
||||
}
|
||||
}
|
||||
if (!xmlFile.exists()) {
|
||||
log.error("XML file to save does not exists!");
|
||||
notifyWithCode(resultContainer, StageResult.ERROR);
|
||||
return StageResult.ERROR;
|
||||
}
|
||||
String newNameOfFile = TimeUtil.formatInstant(Instant.now(), FORMATTER) + '_' + xmlFile.getName();
|
||||
|
|
@ -59,13 +63,20 @@ public class ChangeDirOfFileStage {
|
|||
Files.move(xmlFile.toPath(), outDir.toPath().resolve(newNameOfFile), REPLACE_EXISTING);
|
||||
} catch (IOException e) {
|
||||
log.error("Could not move file {}", e.getMessage());
|
||||
notifyWithCode(resultContainer, StageResult.ERROR);
|
||||
return StageResult.ERROR;
|
||||
}
|
||||
|
||||
if (resultContainer.getLastStageStatus().equals(StageResult.ERROR)) {
|
||||
notifyWithCode(resultContainer, StageResult.ERROR);
|
||||
return StageResult.ERROR;
|
||||
} else {
|
||||
notifyWithCode(resultContainer, StageResult.COMPLETE);
|
||||
return StageResult.COMPLETE;
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyWithCode(ResultContainer resultContainer, StageResult result) {
|
||||
log.info("uuid {}. Stage change directory of file finished with status {}", resultContainer.getUuid(), result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ public class ImportToDB {
|
|||
}
|
||||
|
||||
public StageResult process(ResultContainer resultContainer) {
|
||||
log.info("uuid {}. Stage: Import to DB", resultContainer.getUuid());
|
||||
ETable currTable = resultContainer.getXmlTable();
|
||||
File xmlFile = resultContainer.getXmlFile();
|
||||
DocumentTag documentTag;
|
||||
|
|
@ -45,6 +46,7 @@ public class ImportToDB {
|
|||
} catch (IOException e) {
|
||||
log.error(ExceptionUtils.getStackTrace(e));
|
||||
kafkaMessenger.notifyUserAboutErrorParsing(e, resultContainer);
|
||||
log.info("uuid {}. Stage import to DB finished with status {}", resultContainer.getUuid(), StageResult.ERROR);
|
||||
return StageResult.ERROR;
|
||||
}
|
||||
|
||||
|
|
@ -71,6 +73,7 @@ public class ImportToDB {
|
|||
kafkaMessenger.notifySystemIfNeeded(currTable, fileId);
|
||||
kafkaMessenger.notifyUserAboutSuccessLoad(resultContainer);
|
||||
|
||||
log.info("uuid {}. Stage import to DB finished with status {}", resultContainer.getUuid(), StageResult.OK);
|
||||
return StageResult.OK;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,11 +54,7 @@ public class XMLImporterService {
|
|||
}
|
||||
|
||||
public void processTable(ETable specificTable) {
|
||||
if (specificTable == null) {
|
||||
log.trace("adding import task");
|
||||
} else {
|
||||
log.info("adding import task {}", specificTable);
|
||||
}
|
||||
log.info("adding import task {}", specificTable == null ? "without specific table" : specificTable);
|
||||
|
||||
//fileChecker.checkAndLoadSFTP();
|
||||
executorService.execute(() -> {
|
||||
|
|
@ -91,14 +87,8 @@ public class XMLImporterService {
|
|||
|
||||
log.info("uuid {}. Task started", task.getUuid());
|
||||
long startMills = System.currentTimeMillis();
|
||||
|
||||
log.info("uuid {}. Stage: Import to DB", task.getUuid());
|
||||
task.setLastStageStatus(importToDB.process(task));
|
||||
log.info("uuid {}. Stage import to DB finished with status {}", task.getUuid(), task.getLastStageStatus());
|
||||
log.info("uuid {}. Stage: Change directory of file", task.getUuid());
|
||||
task.setLastStageStatus(changeDirOfFileStage.process(task));
|
||||
log.info("uuid {}. Stage change directory of file finished with status {}", task.getUuid(), task.getLastStageStatus());
|
||||
|
||||
long endMills = System.currentTimeMillis();
|
||||
log.info("uuid {}. Task completed, result: {}, time working: {} ms",
|
||||
task.getUuid(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue