2 * BioJava development code
4 * This code may be freely distributed and modified under the
5 * terms of the GNU Lesser General Public Licence. This should
6 * be distributed with the code. If you do not have a copy,
9 * http://www.gnu.org/copyleft/lesser.html
11 * Copyright for this code is held jointly by the individual
12 * authors. These should be listed in @author doc comments.
14 * For more information on the BioJava project and its aims,
15 * or to join the biojava-l mailing list, visit the home page
18 * http://www.biojava.org/
20 * Created on Mar 23, 2006
23 package org.biojava.dasobert.das2;
25 //import org.biojava.bio.program.das.dasalignment.DASException;
26 import org.biojava.dasobert.dasregistry.Das1Source;
28 public class DasSourceConverter {
30 public DasSourceConverter() {
36 /** convert a das2 source to a das 1 source.
37 * This only will work if is passes the Das2Source.isDas1Source() test
38 * i.e. this is really a das1 server there
40 * @param das2source a DAS2Source to be converted
41 * @return a Das1Source
42 * @throws DASException
44 public static Das1Source toDas1Source (Das2Source das2source) throws Exception{
45 if ( ! das2source.hasDas1Capabilities())
46 throw new Exception("this das source does not have das1 capabilitites");
48 Das1Source ds = new Das1Source();
49 ds.setAdminemail(das2source.getAdminemail());
50 ds.setDescription(das2source.getDescription());
51 ds.setHelperurl(das2source.getHelperurl());
52 ds.setRegisterDate(das2source.getRegisterDate());
53 ds.setLeaseDate(das2source.getLeaseDate());
54 ds.setLabels(das2source.getLabels());
55 ds.setCoordinateSystem(das2source.getCoordinateSystem());
56 ds.setNickname(das2source.getNickname());
57 ds.setId(das2source.getId());
58 ds.setLabels(das2source.getLabels());
60 // convert the capabilitites to das1 capabiltities and get the url
61 Das2Capability[] caps = das2source.getDas2Capabilities();
62 String[] das1capabilitites = new String[caps.length];
63 int DASPREFIXLENGTH = Das2CapabilityImpl.DAS1_CAPABILITY_PREFIX.length();
65 for ( int i = 0 ; i< caps.length;i++){
66 Das2Capability cap = caps[i];
68 String c = cap.getCapability();
70 das1capabilitites[i] = c.substring(DASPREFIXLENGTH,c.length());
72 String query_uri = cap.getQueryUri();
74 String url = query_uri.substring(0,(query_uri.length() - c.length() + DASPREFIXLENGTH));
77 ds.setCapabilities(das1capabilitites);