valia.tsagkalidou 2008-10-14 12:41:05 +00:00
parent 9c006d7c9b
commit d9b880b3ea
1 changed files with 42 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package org.gcube.application.framework.core.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -11,6 +12,10 @@ import org.gcube.application.framework.core.commons.model.SearchField;
*
*/
public class FindInfo {
public static final String ALL = "ALL";
public static final String NAME = "NAME";
public static final String DESCRIPTION = "DESCRIPTION";
public static CollectionInfo findCollectionInfo(String colID, List<CollectionInfo>[] collections)
{
@ -45,6 +50,43 @@ public class FindInfo {
return null;
}
public static List<CollectionInfo> searchCollectionInfo(String term, String whereToSearch, List<CollectionInfo>[] collections)
{
boolean name = false, descr = false;
if(whereToSearch.equals(FindInfo.ALL))
{
name = true;
descr = true;
}
else if(whereToSearch.equals(FindInfo.NAME))
{
name = true;
}
else if(whereToSearch.equals(FindInfo.DESCRIPTION))
{
descr = true;
}
List<CollectionInfo> res = new ArrayList<CollectionInfo>();
for(int counter=0; counter < collections.length;counter++)
{
for(int c2=0; c2 < collections[counter].size(); c2++)
{
if(name && collections[counter].get(c2).getName().toLowerCase().contains(term.toLowerCase()))
{
res.add(collections[counter].get(c2));
continue;
}
if(descr && collections[counter].get(c2).getDescription().toLowerCase().contains(term.toLowerCase()))
{
res.add(collections[counter].get(c2));
continue;
}
}
}
return res;
}
public static int findCollectionSchema(String schemaName, CollectionInfo collection)
{
for(int counter =0; counter < collection.getMetadataSize(); counter++)