Changeset 1198
- Timestamp:
- 02/07/10 11:08:58 (7 months ago)
- Location:
- ide/trunk/src/org/korsakow/domain
- Files:
-
- 3 modified
-
command/ExportFlashProjectCommand.java (modified) (7 diffs)
-
mapper/input/MapperHelper.java (modified) (2 diffs)
-
mapper/input/MediaInputMapper.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ide/trunk/src/org/korsakow/domain/command/ExportFlashProjectCommand.java
r1060 r1198 15 15 import org.korsakow.domain.interf.IMedia; 16 16 import org.korsakow.domain.interf.IProject; 17 import org.korsakow.domain.interf.IResource;18 17 import org.korsakow.domain.interf.ISettings; 19 18 import org.korsakow.domain.interf.ISound; 20 19 import org.korsakow.domain.interf.IText; 21 20 import org.korsakow.domain.interf.IVideo; 22 import org.korsakow.domain.mapper.input.M apperHelper;21 import org.korsakow.domain.mapper.input.MediaInputMapper; 23 22 import org.korsakow.domain.mapper.input.ProjectInputMapper; 24 23 import org.korsakow.domain.task.ITask; 25 24 import org.korsakow.domain.task.IWorker; 26 import org.korsakow.ide.DataRegistry;27 25 import org.korsakow.ide.lang.LanguageBundle; 28 26 import org.korsakow.ide.task.AbstractTask; 29 27 import org.korsakow.ide.task.UIWorker; 30 import org.korsakow.ide.util.DomUtil;31 28 32 29 … … 70 67 private static class SetupExporterTask extends AbstractTask 71 68 { 72 private IWorker uiWorker;73 private File exportDir;74 private Exporter exporter;75 private long projectId;69 private final IWorker uiWorker; 70 private final File exportDir; 71 private final Exporter exporter; 72 private final long projectId; 76 73 public SetupExporterTask(IWorker uiWorker, Exporter exporter, File exportDir, long projectId) 77 74 { … … 82 79 } 83 80 81 @Override 84 82 public void runTask() throws Exception { 85 83 UoW.newCurrent(); … … 88 86 ISettings settings = project.getSettings(); 89 87 90 Collection<IMedia> media = project.getMedia();88 Collection<IMedia> media = MediaInputMapper.findReferencedMedia(); 91 89 Collection<ISound> sounds = new HashSet<ISound>(); 92 90 Collection<IVideo> videos = new HashSet<IVideo>(); … … 98 96 for (IMedia medium : media) 99 97 { 100 System.gc(); // findResourcesReferencing can be a large task on big projects101 102 98 fireProgressChanged(0, ++i*100/size); 103 99 fireDisplayStringChanged("", medium.getName()); 104 // Thread.sleep(70); // this is a completely unreliable way of giving the publish a chance to run105 // // don't export unused media since it takes long and uses up space, which especially is important for web.106 Collection<IResource> referers = MapperHelper.findResourcesReferencing(medium.getId());107 if (referers.isEmpty())108 continue;109 100 110 101 if (medium instanceof ISound) … … 123 114 } 124 115 long after = System.currentTimeMillis(); 125 // System.out.println("Determination: " + (after-before)/1000);116 System.out.println("Determination: " + (after-before)/1000 + "\t" + media.size()); 126 117 127 118 … … 139 130 uiWorker.addTasks(exportTasks); 140 131 } 132 @Override 141 133 public String getTitleString() 142 134 { -
ide/trunk/src/org/korsakow/domain/mapper/input/MapperHelper.java
r1022 r1198 28 28 public class MapperHelper 29 29 { 30 public static final String[] REFERENCING_ELEMENTS = { 31 "backgroundSoundId", 32 "backgroundImageId", 33 "clickSoundId", 34 "splashScreenMediaId", 35 "soundId", 36 "textId", 37 "imageId", 38 "mainMediaId", 39 "videoId", 40 "snuId", 41 "mediaId", 42 "startingSnuId", 43 "interfaceId", 44 "previewMediaId" 45 }; 30 46 /** 31 47 * This is a terrible implementation. … … 98 114 Set<IResource> references = new HashSet<IResource>(); 99 115 100 String[] REFERENCING_ELEMENTS = { 101 "backgroundSoundId", 102 "backgroundImageId", 103 "clickSoundId", 104 "splashScreenMediaId", 105 "soundId", 106 "textId", 107 "imageId", 108 "mainMediaId", 109 "videoId", 110 "snuId", 111 "mediaId", 112 "startingSnuId", 113 "interfaceId", 114 "previewMediaId" 115 }; 116 // // TODO: obviously maintaining this list is not the way to go 116 // // TODO: obviously maintaining this list is not the way to go 117 117 // // I would like to have it so the structure clearly differentiates between an ID declaration and 118 118 // // a reference to an object's id -
ide/trunk/src/org/korsakow/domain/mapper/input/MediaInputMapper.java
r1044 r1198 4 4 import java.util.ArrayList; 5 5 import java.util.Collection; 6 import java.util.HashSet; 6 7 import java.util.List; 8 import java.util.Set; 7 9 8 10 import javax.xml.xpath.XPathExpressionException; … … 13 15 import org.korsakow.domain.interf.IMedia; 14 16 import org.korsakow.domain.interf.IResource; 17 import org.korsakow.ide.DataRegistry; 15 18 import org.korsakow.services.finder.ResourceFinder; 16 19 import org.w3c.dom.Element; … … 57 60 } 58 61 } 62 public static Collection<IMedia> findReferencedMedia() throws MapperException, DomainObjectCreationException, XPathExpressionException, SQLException 63 { 64 Set<IMedia> referenced = new HashSet<IMedia>(); 65 66 // // TODO: obviously maintaining this list is not the way to go 67 // // I would like to have it so the structure clearly differentiates between an ID declaration and 68 // // a reference to an object's id 69 // // something along the lines of <Snu><mainMedia><refId>1</refId></mainMedia></Snu> 70 for (String ELEMENT : MapperHelper.REFERENCING_ELEMENTS) 71 { 72 NodeList elements = DataRegistry.getDocument().getElementsByTagName(ELEMENT); 73 int length = elements.getLength(); 74 for (int i = 0; i < length; ++i) { 75 Element element = (Element)elements.item(i); 76 long refId = Long.parseLong(element.getTextContent()); 77 IResource resource = ResourceInputMapper.map(refId); 78 if (resource instanceof IMedia) 79 referenced.add((IMedia)resource); 80 } 81 } 82 return referenced; 83 } 59 84 }
