create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / database / ComponentPresetDao.java
index 17a85c4ea1c48e2264a064ccf81e9ce7e96a23d5..a27a7f5d424304295d84c631ea261be95a019b82 100644 (file)
@@ -1,45 +1,33 @@
 package net.sf.openrocket.database;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
 import java.util.List;
 
-import net.sf.openrocket.file.preset.PresetCSVReader;
 import net.sf.openrocket.preset.ComponentPreset;
-import net.sf.openrocket.preset.InvalidComponentPresetException;
-import net.sf.openrocket.preset.TypedPropertyMap;
-import net.sf.openrocket.util.BugException;
 
-public class ComponentPresetDao {
+public interface ComponentPresetDao {
 
-       private final List<ComponentPreset> templates = new ArrayList<ComponentPreset>();
-
-       // Package scope constructor to control creation pattern.
-       ComponentPresetDao() {}
+       public List<ComponentPreset> listAll();
        
-       void initialize() throws IOException {
-               
-               InputStream is = ComponentPresetDao.class.getResourceAsStream("/datafiles/bodytubepresets.csv");
-               
-               PresetCSVReader parser = new PresetCSVReader(is);
-               List<TypedPropertyMap> list = parser.parse();
-               for( TypedPropertyMap o : list ) {
-                       try {
-                               ComponentPreset preset = ComponentPreset.create(o);
-                               this.insert(preset);
-                       } catch ( InvalidComponentPresetException ex ) {
-                               throw new BugException( ex );
-                       }
-               }
-       }
+       public void insert( ComponentPreset preset );
+
+       public List<ComponentPreset> listForType( ComponentPreset.Type type );
+
+       /**
+        * Return a list of component presets based on the type.
+        * All components returned will be of Type type.
+        * 
+        * @param type  
+        * @param favorite if true, only return the favorites.  otherwise return all matching.
+        * @return
+        */
+       public List<ComponentPreset> listForType( ComponentPreset.Type type, boolean favorite );
+
+       public List<ComponentPreset> listForTypes( ComponentPreset.Type ... type );
        
-       public List<ComponentPreset> listAll() {
-               return templates;
-       }
+       public List<ComponentPreset> listForTypes( List<ComponentPreset.Type> types );
+
+       public void setFavorite( ComponentPreset preset, ComponentPreset.Type type, boolean favorite );
        
-       public void insert( ComponentPreset preset ) {
-               templates.add(preset);
-       }
+       public List<ComponentPreset> find( String manufacturer, String partNo );
        
-}
+}
\ No newline at end of file