public static DatasourceType asDatasourceType(DataSource dataSource) { DatasourceType datasourceType = new ObjectFactory().createDatasourceType(); datasourceType.setId(dataSource.getId()); datasourceType.setName(dataSource.getName()); datasourceType.setBaseUrl(dataSource.getBaseUrl()); datasourceType.setDirectory(dataSource.getDirectory()); datasourceType.setAction(ActionType.fromValue(dataSource.getAction())); return datasourceType; }
private Set<String> collectURIs(DataSource source) { Set<String> result = new HashSet<>(); switch (type) { case File: for (File file : source.getFiles()) result.add(file.getUri()); break; case Map: for (Map map : source.getMaps()) result.add(map.getUri()); break; case Theme: for (Theme theme : source.getThemes()) result.add(theme.getUri()); break; } return result; }
public Downloadable getDownloadable(String url) { for (DataSource dataSource : getDataSources()) { if(!url.startsWith(dataSource.getBaseUrl())) continue; String uri = url.substring(dataSource.getBaseUrl().length()); Downloadable downloadable = dataSource.getDownloadable(uri); if (downloadable != null) return downloadable; } return null; }
public void downloadDataSources(List<DataSource> dataSources, java.io.File directory) { List<Download> downloads = new ArrayList<>(); for (DataSource dataSource : dataSources) { String datasourceUrl = dataSource.getHref() + FORMAT_XML; java.io.File file = new java.io.File(directory, dataSource.getId() + DOT_XML); Download download = downloadManager.queueForDownload("Datasource: " + dataSource.getId(), datasourceUrl, Copy, new FileAndChecksum(file, null), null); downloads.add(download); } downloadManager.waitForCompletion(downloads); }
private String toXml(DataSource dataSource, java.util.Map<FileAndChecksum, List<FileAndChecksum>> fileToFragments, String... filterUrls) throws IOException { DatasourceType datasourceType = asDatasourceType(dataSource); for (File aFile : dataSource.getFiles()) { if (!contains(filterUrls, dataSource.getBaseUrl() + aFile.getUri())) continue; for (slash.navigation.datasources.Map map : dataSource.getMaps()) { if (!contains(filterUrls, dataSource.getBaseUrl() + map.getUri())) continue; for (Theme theme : dataSource.getThemes()) { if (!contains(filterUrls, dataSource.getBaseUrl() + theme.getUri())) continue;
public synchronized DataSource getDataSourceByUrlPrefix(String url) { for (DataSource dataSource : getDataSources()) { if (url.startsWith(dataSource.getBaseUrl())) return dataSource; } return null; }
File directory = getApplicationDirectory(dataSource.getDirectory()); String directoryPath = directory.getCanonicalPath(); String fileName = filePath.substring(directoryPath.length() + 1); Downloadable downloadable = dataSource.getDownloadable(fileName); if (downloadable != null) return downloadable; Fragment<Downloadable> fragment = dataSource.getFragment(fileName); if (fragment != null) return fragment.getDownloadable(); downloadable = dataSource.getDownloadableBySHA1(sha1); if (downloadable != null) return downloadable; fragment = dataSource.getFragmentBySHA1(sha1); if (fragment != null) return fragment.getDownloadable();
private Download download(Downloadable downloadable) { List<FileAndChecksum> fragments = new ArrayList<>(); for (Fragment otherFragments : downloadable.getFragments()) { String key = otherFragments.getKey(); // ignore fragment keys without extension which are reported by old RouteConverter releases if (key.endsWith(DOT_HGT)) fragments.add(new FileAndChecksum(createFile(key), otherFragments.getLatestChecksum())); } String uri = downloadable.getUri(); String url = getBaseUrl() + uri; return downloadManager.queueForDownload(getName() + " Elevation Tile: " + uri, url, Action.valueOf(dataSource.getAction()), new FileAndChecksum(getDirectory(), downloadable.getLatestChecksum()), fragments); }
public java.io.File getDirectory() { String directoryName = getPath(); java.io.File f = new java.io.File(directoryName); if (!f.exists()) directoryName = getApplicationDirectory(dataSource.getDirectory()).getAbsolutePath(); return ensureDirectory(directoryName); }
if (isInitialized()) { for (String key : uris) { Downloadable downloadable = getSegments().getDownloadable(key); if (downloadable != null) { if (!createSegmentFile(downloadable.getUri()).exists()) for (Downloadable downloadable : getProfiles().getFiles()) { if (!createProfileFile(downloadable.getUri()).exists()) notExistingProfiles.add(downloadable);
public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; DataSource dataSource = (DataSource) o; return getId().equals(dataSource.getId()); }
public String getName() { return dataSource.getName(); }
File centerFile = null; for (File file : dataSource.getFiles()) { BoundingBox fileBoundingBox = file.getBoundingBox(); if (fileBoundingBox == null) {
public List<RemoteTheme> getThemes() { List<RemoteTheme> result = new ArrayList<>(); for (Theme theme : dataSource.getThemes()) { result.add(new RemoteThemeImpl(dataSource, theme)); } return result; } }
public List<RemoteMap> getMaps() { List<RemoteMap> result = new ArrayList<>(); for (slash.navigation.datasources.Map map : dataSource.getMaps()) { result.add(new RemoteMapImpl(dataSource, map)); } return result; }
public String getUrl() { return datasource.getBaseUrl() + downloadable.getUri(); } }
private Download download(Downloadable downloadable) { String uri = downloadable.getUri(); String url = getBaseUrl() + uri; return downloadManager.queueForDownload(getName() + " Routing Data: " + uri, url, Action.valueOf(dataSource.getAction()), new FileAndChecksum(createFile(downloadable.getUri()), downloadable.getLatestChecksum()), null); }
private java.io.File getDirectory(DataSource dataSource, String directoryName) { String path = getPath() + "/" + directoryName; java.io.File f = new java.io.File(path); if (!f.exists()) directoryName = getApplicationDirectory(dataSource.getDirectory()).getAbsolutePath(); return ensureDirectory(directoryName); }
public synchronized DataSource getDataSourceById(String id) { for (DataSource dataSource : getDataSources()) { if (id.equals(dataSource.getId())) return dataSource; } return null; }