|
|
|
@ -10,6 +10,8 @@ import com.fr.workspace.WorkContext;
|
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.OutputStreamWriter; |
|
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
import java.sql.Blob; |
|
|
|
|
import java.sql.Connection; |
|
|
|
|
import java.sql.DriverManager; |
|
|
|
@ -62,9 +64,9 @@ public class ConfigToPropMigrator {
|
|
|
|
|
initDirectory(); |
|
|
|
|
|
|
|
|
|
try (Connection c = DriverManager.getConnection(url); |
|
|
|
|
FileOutputStream entityOut = new FileOutputStream(PropertiesConstants.ENTITY_PROP_PATH); |
|
|
|
|
FileOutputStream classHelperOut = new FileOutputStream(PropertiesConstants.CLASS_NAME_PROP_PATH); |
|
|
|
|
FileOutputStream xmlEntityOut = new FileOutputStream(PropertiesConstants.XML_ENTITY_PROP_PATH)) { |
|
|
|
|
OutputStreamWriter xmlEntityOut = new OutputStreamWriter(new FileOutputStream(PropertiesConstants.XML_ENTITY_PROP_PATH), StandardCharsets.UTF_8); |
|
|
|
|
OutputStreamWriter entityOut = new OutputStreamWriter(new FileOutputStream(PropertiesConstants.ENTITY_PROP_PATH), StandardCharsets.UTF_8); |
|
|
|
|
OutputStreamWriter classHelperOut = new OutputStreamWriter(new FileOutputStream(PropertiesConstants.CLASS_NAME_PROP_PATH), StandardCharsets.UTF_8)) { |
|
|
|
|
|
|
|
|
|
processClassOrEntity(c, new Properties(), SELECT_FOR_ENTITY, entityOut); |
|
|
|
|
processClassOrEntity(c, new Properties(), SELECT_FOR_CLASSNAME, classHelperOut); |
|
|
|
@ -84,7 +86,7 @@ public class ConfigToPropMigrator {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void processClassOrEntity(Connection c, Properties map, String sql, FileOutputStream outputStream) throws SQLException, IOException { |
|
|
|
|
private void processClassOrEntity(Connection c, Properties map, String sql, OutputStreamWriter writer) throws SQLException, IOException { |
|
|
|
|
PreparedStatement query = c.prepareStatement(sql); |
|
|
|
|
ResultSet resultSet = query.executeQuery(); |
|
|
|
|
while (resultSet.next()) { |
|
|
|
@ -94,19 +96,19 @@ public class ConfigToPropMigrator {
|
|
|
|
|
map.setProperty(id, value); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
map.store(outputStream, null); |
|
|
|
|
map.store(writer, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void processXmlEntity(Connection c, Properties map, FileOutputStream outputStream) throws SQLException, IOException { |
|
|
|
|
private void processXmlEntity(Connection c, Properties map, OutputStreamWriter writer) throws SQLException, IOException { |
|
|
|
|
PreparedStatement query = c.prepareStatement(SELECT_FOR_XML_ENTITY); |
|
|
|
|
ResultSet resultSet = query.executeQuery(); |
|
|
|
|
while (resultSet.next()) { |
|
|
|
|
String id = resultSet.getString(1); |
|
|
|
|
Blob value = resultSet.getBlob(2); |
|
|
|
|
byte[] bytes = value.getBytes(1L, (int) value.length()); |
|
|
|
|
map.setProperty(id, new String(bytes)); |
|
|
|
|
map.setProperty(id, new String(bytes, StandardCharsets.UTF_8)); |
|
|
|
|
} |
|
|
|
|
map.store(outputStream, null); |
|
|
|
|
map.store(writer, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void deletePropertiesCache() { |
|
|
|
|