git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerCore@4677 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9c006d7c9b
commit
d9b880b3ea
|
@ -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++)
|
||||
|
|
Loading…
Reference in New Issue