//List<DdcClassification> ddcClassList = xsscfDom.getDdcClassification();
List<TaxonomyEntry> taxClassList = xsscfDom.getClassification();
if(xsscf!=null)
{
DirectoryDescription dd = new DirectoryDescription();
//Get name and description
dd.setName(xsscf.getLabel());
dd.setDescription(xsscf.getComment());
XResource xfr = xsscf.getIssuedBy();
if(xfr instanceof Person) {
Person tmp = (Person)xfr;
dd.setOwner(tmp.getName());
}
//list of avaliable taxonomies
Map<String,String> taxonomies = new HashMap<String,String>();
//List of taxonomy values
Map<String,Map<String,String>> taxMap = new HashMap<String, Map<String,String>>();
//list of avaliable thesauri
Map<String,String> thesauri = new HashMap<String,String>();
//List of theasourus values
Map<String,Map<String,String>> thesMap = new HashMap<String, Map<String,String>>();
//get all wordNet values
/* if(wordnetClassList!=null&&!wordnetClassList.isEmpty())
{
String tax1 = "WordNet";
String tax_uri = "";
taxonomies.put(tax1, tax_uri);
Map<String,String> taxValues = new HashMap<String,String>();
for(WordNetClassification wnc : wordnetClassList)
{
taxValues.put(wnc.getURI(),wnc.getName());
}
taxMap.put(tax1, taxValues);
}*/
if(thesClassList!=null&&!thesClassList.isEmpty())
{
Collection<String> contextNames = new ArrayList<String>();
Map<String,Map<String,String>> tmpThesValues = new HashMap<String,Map<String,String>>();
Map<String,String> tmpMapForThesUris = new HashMap<String, String>();
for(ThesaurusEntry thesaurusEntry : thesClassList)
{
KOSContext context = thesaurusEntry.getContext();
Map<String,String> mapToPut = null;
if(!contextNames.contains(context.getLabel()))
{
contextNames.add(context.getLabel());
mapToPut = new HashMap<String, String>();
}
else
{
mapToPut = tmpThesValues.get(context.getLabel());
}
mapToPut.put(thesaurusEntry.getURI().toString(),thesaurusEntry.getLabel());
tmpThesValues.put(context.getLabel(),mapToPut);
if(tmpMapForThesUris.get(context.getLabel())==null)
tmpMapForThesUris.put(context.getLabel(), context.getNamespaceURI());
}
Set<String> thess= tmpThesValues.keySet();
for(String thes:thess)
{
thesauri.put(thes,tmpMapForThesUris.get(thes));
thesMap.put(thes, tmpThesValues.get(thes));
}
}
dd.setThesauri(thesauri);
dd.setThesaurusValues(thesMap);
//old-style ddc classification description fetch.
//TODO: check for DDC implementation
/*if(ddcClassList!=null&&!ddcClassList.isEmpty())
{
String tax1 = "DDC";
String tax_uri = "";
try
{
tax_uri = DdcContext.getContext().getNamespaceURI();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
taxonomies.put(tax1, tax_uri);
Map<String,String> taxValues = new HashMap<String, String>();
for(DdcClassification ddcc : ddcClassList)
{
taxValues.put(ddcc.getURI(),ddcc.getName());
}
taxMap.put(tax1, taxValues);
}*/
//all taxonomies description fetch
if(taxClassList!=null&&!taxClassList.isEmpty())
{
Collection<String> contextNames = new ArrayList<String>();
Map<String,Map<String,String>> tmpTaxValues = new HashMap<String,Map<String,String>>();
Map<String,String> tmpMapForTaxUris = new HashMap<String, String>();
for(TaxonomyEntry taxonomyEntry : taxClassList)
{
KOSContext context = taxonomyEntry.getContext();
Map<String,String> mapToPut = null;
if(!contextNames.contains(context.getLabel()))
{
contextNames.add(context.getLabel());
mapToPut = new HashMap<String, String>();
}
else
{
mapToPut = tmpTaxValues.get(context.getLabel());
}
mapToPut.put(taxonomyEntry.getURI().toString(),taxonomyEntry.getLabel());
tmpTaxValues.put(context.getLabel(),mapToPut);
if(tmpMapForTaxUris.get(context.getLabel())==null)
tmpMapForTaxUris.put(context.getLabel(), context.getNamespaceURI());
}
Set<String> taxes = tmpTaxValues.keySet();
for(String tax:taxes)
{
taxonomies.put(tax,tmpMapForTaxUris.get(tax));
taxMap.put(tax, tmpTaxValues.get(tax));
}
}
dd.setTaxonomies(taxonomies);
dd.setTaxonomyValues(taxMap);
return dd;
}
return null;
}