73 lines
1.9 KiB
Java
73 lines
1.9 KiB
Java
package org.gcube.application.framework.core.util;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
import org.gcube.application.framework.core.commons.model.CollectionInfo;
|
|
import org.gcube.application.framework.core.commons.model.SearchField;
|
|
|
|
/**
|
|
* @author Valia Tsagkalidou (KNUA)
|
|
*
|
|
*/
|
|
public class FindInfo {
|
|
|
|
public static CollectionInfo findCollectionInfo(String colID, List<CollectionInfo>[] collections)
|
|
{
|
|
for(int counter=0; counter < collections.length;counter++)
|
|
{
|
|
for(int c2=1; c2 < collections[counter].size(); c2++)
|
|
{
|
|
if(collections[counter].get(c2).getId().equals(colID))
|
|
{
|
|
return collections[counter].get(c2);
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static CollectionInfo findCollectionInfoFromMetadata(String metadataColID, List<CollectionInfo>[] collections)
|
|
{
|
|
for(int counter=0; counter < collections.length;counter++)
|
|
{
|
|
for(int c2=1; c2 < collections[counter].size(); c2++)
|
|
{
|
|
for(int c3=0; c3 < collections[counter].get(c2).getMetadataSize(); c3++)
|
|
{
|
|
if(collections[counter].get(c2).getMetadataID(c3).equals(metadataColID))
|
|
{
|
|
return collections[counter].get(c2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static int findCollectionSchema(String schemaName, CollectionInfo collection)
|
|
{
|
|
for(int counter =0; counter < collection.getMetadataSize(); counter++)
|
|
{
|
|
if(collection.getSchema(counter).equals(schemaName))
|
|
{
|
|
return counter;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public static int findCriterion(String name, String schemaName, HashMap<String, List<SearchField>> SchemaHashMap)
|
|
{
|
|
List<SearchField> schemaCriteria = SchemaHashMap.get(schemaName);
|
|
for(int counter = 0; counter < schemaCriteria.size(); counter++)
|
|
{// finding details regarding this criterion
|
|
if(schemaCriteria.get(counter).name.equals(name))
|
|
{
|
|
return counter;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
}
|