|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
net.datacrow.core.services.SearchTask
public abstract class SearchTask
A search task performs the actual online search. The search task is used by the
online search form (see OnlineSearchForm
) and by processed such as the mass
update.
The search is performed in multiple steps.
1) First the online service (web page or web server) is queried using the input
of the user (getItemKeys()
).
2) For each result the item details are retrieved. See (run()
) and
#getItems(String, boolean)
3) The in step 2 retrieved items only contain the bare minimum of information.
When the user (or any other process) selects one of the items the full details
need to be retrieved (getItem(URL)
)
This class needs to be extended for specific implementations.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
static int |
_ITEM_MODE_FULL
|
static int |
_ITEM_MODE_SIMPLE
|
protected IOnlineSearchClient |
listener
|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
SearchTask(IOnlineSearchClient listener,
IServer server,
Region region,
SearchMode mode,
java.lang.String query)
Creates the search task. |
Method Summary | |
---|---|
void |
cancel()
Cancel the search. |
java.lang.String |
getAddress()
The currently used URL or address. |
DcObject |
getClient()
|
protected abstract DcObject |
getItem(java.lang.Object key,
boolean full)
Query for the item using the web key. |
protected abstract DcObject |
getItem(java.net.URL url)
Query for the item via the URL |
protected abstract java.util.Collection<java.lang.Object> |
getItemKeys()
Get every web ID from the page. |
int |
getItemMode()
Returns the retrieval mode: _ITEM_MODE_FULL or _ITEM_MODE_SIMPLE . |
protected java.util.Collection<DcObject> |
getItems(java.lang.Object key,
boolean full)
Query for the item(s) using the web key. |
int |
getMaximum()
The maximum amount of items to be retrieved. |
SearchMode |
getMode()
The currently used search mode. |
java.lang.String |
getQuery()
The used query as specified by the user. |
Region |
getRegion()
The currently used region |
IServer |
getServer()
The currently used server |
java.lang.String |
getWhiteSpaceSubst()
The character used to substitute white spaces from the query (see getQuery() ). |
boolean |
isCancelled()
Indicates if the search was (attempted) to be canceled. |
boolean |
isItemModeSupported()
|
protected void |
preSearchCheck()
|
DcObject |
query(DcObject dco)
Queries for the specified item. |
void |
run()
Here the actual search is performed. |
void |
setClient(DcObject client)
|
void |
setItemMode(int mode)
Sets the item retrieval mode: _ITEM_MODE_FULL or _ITEM_MODE_SIMPLE . |
void |
setMaximum(int maximum)
Set the maximum amount of items to be retrieved. |
void |
setMode(SearchMode searchMode)
|
void |
setQuery(java.lang.String query)
|
protected void |
setServiceInfo(DcObject dco)
Sets the service info. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int _ITEM_MODE_SIMPLE
public static final int _ITEM_MODE_FULL
protected IOnlineSearchClient listener
Constructor Detail |
---|
public SearchTask(IOnlineSearchClient listener, IServer server, Region region, SearchMode mode, java.lang.String query)
listener
- server
- region
- mode
- query
- Method Detail |
---|
protected final void setServiceInfo(DcObject dco)
public final void setItemMode(int mode)
_ITEM_MODE_FULL
or _ITEM_MODE_SIMPLE
.
public boolean isItemModeSupported()
public final int getItemMode()
_ITEM_MODE_FULL
or _ITEM_MODE_SIMPLE
.
public final void setMaximum(int maximum)
public final void cancel()
public final boolean isCancelled()
public final java.lang.String getAddress()
public final SearchMode getMode()
SearchMode
public final Region getRegion()
Region.
public DcObject getClient()
public void setClient(DcObject client)
public void setQuery(java.lang.String query)
public void setMode(SearchMode searchMode)
public java.lang.String getQuery()
public final IServer getServer()
IServer
public final int getMaximum()
public java.lang.String getWhiteSpaceSubst()
getQuery()
).
Should be overridden by specific implementations.
public DcObject query(DcObject dco) throws java.lang.Exception
setServiceInfo(DcObject)
)
is used to retrieve the information.
dco
- The item to be updated.
java.lang.Exception
protected java.util.Collection<DcObject> getItems(java.lang.Object key, boolean full) throws java.lang.Exception
key
- The item key (The specific implementation decides the meaning of a key)full
- Indicates if the full details should be retrieved.
java.lang.Exception
protected abstract DcObject getItem(java.lang.Object key, boolean full) throws java.lang.Exception
key
- The item key (The specific implementation decides the meaning of a key)full
- Indicates if the full details should be retrieved.
java.lang.Exception
protected abstract DcObject getItem(java.net.URL url) throws java.lang.Exception
url
- The direct link to the external item details.
java.lang.Exception
protected abstract java.util.Collection<java.lang.Object> getItemKeys() throws java.lang.Exception
java.lang.Exception
protected void preSearchCheck()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |