Add Dave Cook's parts database as a git submodule, in a directory called swing/swing/resources-src/datafiles/components/
Move old rocksim-based database from .../presets to .../legacy_components Move rocksim .csv files from .../rocksim_components to .../rocksim_src Modify BaseComponentDTO to process units Modify SerializePresets to take a set of directories containing .orc files as command-line arguments, and process all of them. Modify swing/build.xml to specify both legacy and new databases for import
This commit is contained in:
parent
7fdd0ed5c7
commit
71202abfdc
@ -228,14 +228,16 @@ public abstract class BaseComponentDTO {
|
|||||||
|
|
||||||
static class AnnotatedLengthDTO {
|
static class AnnotatedLengthDTO {
|
||||||
@XmlAttribute(name = "Unit", required = false)
|
@XmlAttribute(name = "Unit", required = false)
|
||||||
private final String unitName = "m";
|
private final String unitName;
|
||||||
@XmlValue
|
@XmlValue
|
||||||
private double length;
|
private double length;
|
||||||
|
|
||||||
AnnotatedLengthDTO() {
|
AnnotatedLengthDTO() {
|
||||||
|
this.unitName = "m";
|
||||||
}
|
}
|
||||||
|
|
||||||
AnnotatedLengthDTO(double length) {
|
AnnotatedLengthDTO(double length) {
|
||||||
|
this.unitName = "m";
|
||||||
this.length = length;
|
this.length = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,14 +248,16 @@ public abstract class BaseComponentDTO {
|
|||||||
|
|
||||||
static class AnnotatedMassDTO {
|
static class AnnotatedMassDTO {
|
||||||
@XmlAttribute(name = "Unit", required = false)
|
@XmlAttribute(name = "Unit", required = false)
|
||||||
private final String unitName = "kg";
|
private final String unitName;
|
||||||
@XmlValue
|
@XmlValue
|
||||||
private double mass;
|
private double mass;
|
||||||
|
|
||||||
AnnotatedMassDTO() {
|
AnnotatedMassDTO() {
|
||||||
|
unitName = "kg";
|
||||||
}
|
}
|
||||||
|
|
||||||
AnnotatedMassDTO(double mass) {
|
AnnotatedMassDTO(double mass) {
|
||||||
|
unitName = "kg";
|
||||||
this.mass = mass;
|
this.mass = mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +129,8 @@
|
|||||||
fork="true"
|
fork="true"
|
||||||
classpathref="run-classpath"
|
classpathref="run-classpath"
|
||||||
failonerror="true">
|
failonerror="true">
|
||||||
|
<arg value="resources-src/datafiles/legacy_components"/>
|
||||||
|
<arg value="resources-src/datafiles/components/orc"/>
|
||||||
</java>
|
</java>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
@ -138,7 +140,7 @@
|
|||||||
<attribute name="vendor"/>
|
<attribute name="vendor"/>
|
||||||
<sequential>
|
<sequential>
|
||||||
<echo>Generating ORC file for vendor @{vendor}</echo>
|
<echo>Generating ORC file for vendor @{vendor}</echo>
|
||||||
<java classname="net.sf.openrocket.preset.loader.RocksimComponentFileTranslator"
|
<java classname="net.sf.openrocket.utils.RocksimComponentFileTranslator"
|
||||||
fork="true"
|
fork="true"
|
||||||
classpathref="run-classpath"
|
classpathref="run-classpath"
|
||||||
failonerror="true">
|
failonerror="true">
|
||||||
|
Binary file not shown.
@ -18,6 +18,11 @@ import net.sf.openrocket.util.Pair;
|
|||||||
|
|
||||||
public class SerializePresets extends BasicApplication {
|
public class SerializePresets extends BasicApplication {
|
||||||
|
|
||||||
|
private static void printUsage() {
|
||||||
|
System.err.println("SerializePresets <dir> ... ");
|
||||||
|
System.err.println("<dir> (may be repeated) is base directory for a set of .orc preset files");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
@ -26,15 +31,24 @@ public class SerializePresets extends BasicApplication {
|
|||||||
SerializePresets app = new SerializePresets();
|
SerializePresets app = new SerializePresets();
|
||||||
app.initializeApplication();
|
app.initializeApplication();
|
||||||
|
|
||||||
|
if (args.length < 1) {
|
||||||
|
printUsage();
|
||||||
|
throw new IllegalArgumentException("Invalid Command Line Params");
|
||||||
|
}
|
||||||
|
|
||||||
Locale.setDefault(Locale.ENGLISH);
|
Locale.setDefault(Locale.ENGLISH);
|
||||||
|
|
||||||
ComponentPresetDatabase componentPresetDao = new ComponentPresetDatabase();
|
ComponentPresetDatabase componentPresetDao = new ComponentPresetDatabase();
|
||||||
|
|
||||||
FileIterator iterator = DirectoryIterator.findDirectory("resources-src/datafiles/presets", new SimpleFileFilter("", false, "orc"));
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
|
||||||
|
System.err.println("Processing .orc files in directory " + args[i]);
|
||||||
|
|
||||||
|
FileIterator iterator = DirectoryIterator.findDirectory(args[i], new SimpleFileFilter("", false, "orc"));
|
||||||
if (iterator == null) {
|
if (iterator == null) {
|
||||||
throw new RuntimeException("Can't find resources-src/presets directory");
|
throw new RuntimeException("Can't find " + args[i] + " directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Pair<String, InputStream> f = iterator.next();
|
Pair<String, InputStream> f = iterator.next();
|
||||||
String fileName = f.getU();
|
String fileName = f.getU();
|
||||||
@ -47,6 +61,8 @@ public class SerializePresets extends BasicApplication {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
List<ComponentPreset> list = componentPresetDao.listAll();
|
List<ComponentPreset> list = componentPresetDao.listAll();
|
||||||
|
|
||||||
System.out.println("Total number of presets = " + list.size());
|
System.out.println("Total number of presets = " + list.size());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user