Change MaterialDTO.asMaterial() to convert the current object into a Material object. It no longer attempts to look it up in the database.
This commit is contained in:
parent
1c0f70806d
commit
00dfe40706
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
package net.sf.openrocket.preset.xml;
|
package net.sf.openrocket.preset.xml;
|
||||||
|
|
||||||
|
import net.sf.openrocket.database.Databases;
|
||||||
import net.sf.openrocket.material.Material;
|
import net.sf.openrocket.material.Material;
|
||||||
import net.sf.openrocket.motor.Manufacturer;
|
import net.sf.openrocket.motor.Manufacturer;
|
||||||
import net.sf.openrocket.preset.ComponentPreset;
|
import net.sf.openrocket.preset.ComponentPreset;
|
||||||
@ -189,17 +190,22 @@ public abstract class BaseComponentDTO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't have one, build one.
|
// Don't have one, first check OR's database
|
||||||
|
Material m = Databases.findMaterial(dto.getORMaterialType(), dto.material);
|
||||||
|
if ( m != null ) {
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
if ( "BULK".equals( dto.type ) ) {
|
switch( dto.getORMaterialType() ) {
|
||||||
|
case BULK:
|
||||||
return new Material.Bulk(dto.material, 0.0, true);
|
return new Material.Bulk(dto.material, 0.0, true);
|
||||||
} else if ( "SURFACE".equals( dto.type ) ) {
|
case SURFACE:
|
||||||
return new Material.Surface(dto.material, 0.0, true);
|
return new Material.Surface(dto.material, 0.0, true);
|
||||||
} else if ( "LINE".equals( dto.type ) ) {
|
case LINE:
|
||||||
return new Material.Line(dto.material, 0.0, true);
|
return new Material.Line(dto.material, 0.0, true);
|
||||||
} else {
|
}
|
||||||
return null;
|
|
||||||
}
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +221,17 @@ public abstract class BaseComponentDTO {
|
|||||||
type = theMaterial.getType().name();
|
type = theMaterial.getType().name();
|
||||||
material = theMaterial.getName();
|
material = theMaterial.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Material.Type getORMaterialType() {
|
||||||
|
if ( "BULK".equals(type) ) {
|
||||||
|
return Material.Type.BULK;
|
||||||
|
} else if ( "SURFACE".equals(type) ) {
|
||||||
|
return Material.Type.SURFACE;
|
||||||
|
} else if ( "LINE".equals(type) ) {
|
||||||
|
return Material.Type.LINE;
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException( "Inavlid material type " + type +" specified for Component" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class AnnotatedLengthDTO {
|
static class AnnotatedLengthDTO {
|
||||||
|
@ -80,7 +80,7 @@ public class MaterialDTO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Material asMaterial() {
|
Material asMaterial() {
|
||||||
return Databases.findMaterial(type.getORMaterialType(), name, density, false);
|
return Material.newMaterial(type.getORMaterialType(), name, density, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user