Archive for July, 2011

Add properties to proserver sources document

in your configuration eg proserver.ini add a properties line with -> seperated key value pairs each sep by ;
 [cath_pdb]
 title = CATH Domains
 ...
 properties = spec -> DAS/1.6E ; label -> eFamily

In this case the spec option tells the DAS registry that this data source is a 1.6 version. This can be used on a per source basis.

Note: you can also situate your proserver.ini file and call it something else by starting proserver with the -c option and specifying where the config file you want to run is.

Advertisements

Adapters in JDAS

The reason for having the adapters package in JDAS is so that getting objects of specific types from the JAXB generated classes is easier. So for example for the registry code I want to get all sources that have a query_uri that has the server url at the start. The two methods below illustrate without adapters and the same method with adapters:

private List<SOURCE> getDas1SourcesForServerUrl(String serverUrl) {
// SOURCES newSources=new SOURCES();
List<SOURCE> serverSources = new ArrayList<SOURCE>();
List<SOURCE> sourceList = storedSources.getSOURCE();
for (SOURCE source : sourceList) {
List<Object> objects = source.getMAINTAINEROrVERSION();
for (Object object : objects) {
if (object instanceof VERSION) {
System.out.println("version found");
VERSION version = (VERSION) object;
for (Object object1 : version
.getCOORDINATESOrCAPABILITYOrPROP()) {
if (object1 instanceof CAPABILITY) {
CAPABILITY cap = (CAPABILITY) object1;
if (cap.getQueryUri().startsWith(serverUrl)) {
System.out
.println("server url found "
+ serverUrl + "in "
+ cap.getQueryUri());
serverSources.add(source);
break;
}
}
System.out.println("serverUrl found" + source.getUri());
}
}
}
}
return sourceList;
}

with adapters:
public List<SOURCE> getSourcesForServerUrl(String serverUrl) {
List<SOURCE> serverSources = new ArrayList<SOURCE>();
List<SOURCE> sourceList = storedSources.getSOURCE();
for (SOURCE source : sourceList) {
try {
SourceAdapter sourceA = new SourceAdapter(source);
List<VersionAdapter> versionAdapters = sourceA.getVersion();
for (VersionAdapter vA : versionAdapters) {
List<CAPABILITY> caps = vA.getCapabilities();
if (caps.size() > 0) {
if (caps.get(0).getQueryUri().startsWith(serverUrl)) {
serverSources.add(source);
}
}
}
} catch (ValidationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return serverSources;
}

although its not much shorter I’m sure you will agree it is easier to read.