ontoSpreadXMLState.setCurrentScore(ontoSpreadState.getCurrentScore());
return ontoSpreadXMLState;
}
public static OntoSpreadState asState(OntoSpreadXMLState ontoSpreadXMLState){
OntoSpreadState ontoSpreadState = new OntoSpreadState();
ScoredConceptTO []initialConcepts = new ScoredConceptTO[ontoSpreadXMLState.getScoredConcepts().getScoredConceptTOs().size()];
int k = 0;
for (ScoredConceptTOType scoredXML : ontoSpreadXMLState.getScoredConcepts().getScoredConceptTOs()) {
ScoredConceptTO scoredConceptTO = new ScoredConceptTO();
scoredConceptTO.setConceptUri(scoredXML.getConceptUri());
scoredConceptTO.setScore(scoredXML.getScore());
initialConcepts[k++] = scoredConceptTO;
}
ontoSpreadState.setInitialConcepts(initialConcepts);
ontoSpreadState.setSpreadTime(ontoSpreadXMLState.getSpreadTime());
Set<String> spreadedConcepts = new HashSet<String>();
for (String uri : ontoSpreadXMLState.getSpreadedConcepts().getSpreadedConcepts()) {
spreadedConcepts.add(uri);
}
ontoSpreadState.setSpreadedConcepts(spreadedConcepts );
Map<String, PathTO[]> spreadPathTable = new HashMap<String, PathTO[]>();
for (EntryPathTableType entry : ontoSpreadXMLState.getSpreadPathTable().getSpreadTableTOs()) {
String key = entry.getUri();
PathTOTypeList pathTOs = entry.getPathTOs();
PathTO []path = new PathTO[pathTOs==null?0:pathTOs.getPathTOs().size()];
if(pathTOs != null){
int i = 0;
for (PathTOType pathTo : pathTOs.getPathTOs()) {
path[i++] = new PathTO(pathTo.getUri(),pathTo.getRelations().getRelations().toArray(new String[pathTo.getRelations().getRelations().size()]));
}
}
spreadPathTable.put(key, path);
}
ontoSpreadState.setSpreadPathTable(spreadPathTable);
SpreadedConceptTO[] result = new SpreadedConceptTO[ontoSpreadXMLState.getFinalSpreadedConcepts().getSpreadedConceptTOs().size()];
int i = 0;
for (SpreadedConceptTOType spreadedXML : ontoSpreadXMLState.getFinalSpreadedConcepts().getSpreadedConceptTOs()){
PathTOTypeList pathTOs = spreadedXML.getPathTOs();
PathTO []path = new PathTO[pathTOs==null?0:pathTOs.getPathTOs().size()];
if(pathTOs != null){
int j = 0;
for (PathTOType pathTo : pathTOs.getPathTOs()) {
path[j++] = new PathTO(pathTo.getUri(),
pathTo.getRelations().getRelations().toArray(new String[pathTo.getRelations().getRelations().size()]));
}
}
double score = spreadedXML.getScore();
result[i++] = new SpreadedConceptTO(new ConceptTO(spreadedXML.getConceptUri()),path,score );
}
ontoSpreadState.setFinalSpreadedConcepts(result);
List<UriDepthPair> sortedList = new LinkedList<UriDepthPair>();
for (UriDepthPairType uriXMLPair : ontoSpreadXMLState.getUriDepthPair().getUriDepthPairs()) {
sortedList.add(new UriDepthPair(uriXMLPair.getConceptUri(),uriXMLPair.getDepth()));
}
ontoSpreadState.setSortedList(sortedList);
Map<String, Double> concepts = new HashMap<String, Double>();
for (EntryConceptsType entryXML : ontoSpreadXMLState.getConcepts().getEntryConceptTOs()) {
concepts.put(entryXML.getUri(), entryXML.getValue());
}
ontoSpreadState.setConcepts(concepts );
HashMap<PathTO, Integer> prizeTable = ontoSpreadState.getConceptsToPrize().getPrizeTable();
for (EntryPrizeTableTOType entry : ontoSpreadXMLState.getPrizeTable().getEntryPrizeTableTOs()) {
int value = entry.getHits();
PathTO pathTO = new PathTO(entry.getPathTO().getUri(),entry.getPathTO().getRelations().getRelations().toArray(new String[entry.getPathTO().getRelations().getRelations().size()]));
prizeTable.put(pathTO , value);
}
ontoSpreadState.setConceptToSpread(new ConceptTO(ontoSpreadXMLState.getConceptTOSpread()));
ontoSpreadState.setHasIteration(ontoSpreadXMLState.isHasIteration());
ontoSpreadState.setCurrentScore(ontoSpreadXMLState.getCurrentScore());
return ontoSpreadState;
}