Integrazione con altre applicazioni > Utilizzo di Creo Parametric con Windchill > Amministrazione e configurazione > Configurazione di Windchill per l'interazione con Creo Parametric > Personalizzazione della pagina di selezione degli oggetti del client HTML > Personalizzazione della ricerca HTML
  
Personalizzazione della ricerca HTML
Per personalizzare la ricerca HTML in modo da modificare la visualizzazione degli oggetti di ricerca di default o aggiungere nuove classi, vedere il file riportato di seguito distribuito come Windchill\src\wt\query\SearchAttributeList di origine. Come illustrato nella documentazione javadoc relativa a questa classe, creare una sottoclasse di SearchAttributeList e inserire le voci appropriate nei file service.properties e wt.properties. Di seguito sono riportati i metodi da implementare in un elenco SearchAttributeList personalizzato con esempi:
public final class MySearchAttributeList extends SearchAttributeList implements
Externalizable {
public void setLocale( Locale locale ) {
// Load in the values for the drop down list for selecting what to search against.
clientLocale = locale;
// **Customize --------------------------------------------------------------
--------------
// Add new classes to search to list below.
// Make sure that they are assigned numbers in sequence from 0 to N.
// Set dropDownListCount to N+1.
final int ALL = 0;
final int WTPART = 1;

final int MYCLASS = 22
int dropDownListCount = 23;
// -------------------------------------------------------------------------
------------…
pickList = new String[classCount];
pickList[ALL] =
WTMessage.getLocalizedMessage(RESOURCE,queryResource.ALL,null,clientLocale);
pickList[WTPART] =
WTMessage.getLocalizedMessage(RESOURCE,queryResource.WTPART,null,clientLocale);

pickList[MYCLASS] = WTMessage.getLocalizedMessage(RESOURCE,queryResource.
MYCLASS,null,clientLocale);
pickValues = new String[classCount];
pickValues[ALL] = queryResource.ALL;
pickValues[WTPART] = queryResource.WTPART;

pickValues[MYCLASS] = queryResource.MYCLASS;
// **Customize You will need a string in here to correspond to each item in
pickList
// The string is a space separated list of what classes to query
// against. If you want to query against multiple classes that have a common
parent that
// has all of the attributes that you are interested in use that one class. If
you want
// to query against multiple classes that don't have a good common parent then
you can
// add them to a list and the search will loop through each class and combine
the results
// at the end. All classes in one list must only search against COMMON
attributes or
// attributes with the same name and of the same class! If you add both a
parent and
// a child class to the list you will get duplicate entries, when the results
are
// combined duplicate entries are not deleted.
queryClass = new String[classCount];
queryClass[ALL] =
"wt.part.WTPart wt.doc.WTDocument wt.change2.WTChangeIssue
wt.change2.WTChangeRequest2 " +
"wt.change2.WTChangeInvestigation wt.change2.WTAnalysisActivity
wt.change2.WTChangeProposal " +
"wt.change2.WTChangeOrder2 wt.change2.WTChangeActivity2
wt.csm.businessentity.BusinessEntity " +
"wt.effectivity.ConfigurationItem wt.epm.EPMDocument " +
"wt.replication.unit.WTUnit " +
"wt.part.WTProductConfiguration " +
"wt.part.WTProductInstance2 "; // Please remember to keep a space at the
end so that conditionally added items work.

queryClass[WTPART] = "wt.part.WTPart";

queryClass[MYCLASS] = "?.?.MyClass";
// **Customize These are the
// attributes that can be queried against.
inputAttributes = new String[classCount];
inputAttributes[ALL] =
"number name lifeCycleState projectId cabinet creator modifier
modifyTimestamp";
inputAttributes[WTPART] =
"number name view versionIdentifier partType source lifeCycleState projectId
cabinet creator modifier modifyTimestamp";

inputAttributes[MYCLASS] =
"name modifyTimestamp";
// **Customize Each individual
// string must match with the string listed above for the inputAttributes. "0"
stands for no
// input processing. If an attribute is an enumerated type use "0" and the
code will generate
// the drop down list. In the first string: projectId is in the fourth
position in inputAttributes
// so the method to generate the drop down list for it is also in the fourth
position in the
// string. The "0"s and methods must match in number with the number of
attributes listed
// under inputAttributes. You may add a fully qualified method from your
customization package
// as long as it is static and returns a vector of strings.
inputProcessing = new String[classCount];
inputProcessing[ALL] =
"0 0 0 wt.query.LocalSearchProcessor.getProjectList
wt.query.LocalSearchProcessor.getCabinetList 0 0 0";
inputProcessing[WTPART] =
"0 0 wt.query.LocalSearchProcessor.getViewList 0 0 0 0
wt.query.LocalSearchProcessor.getProjectList
wt.query.LocalSearchProcessor.getCabinetList 0 0 0";

inputProcessing[MYCLASS] =
"0 0";
// **Customize This is similar in concept to inputAttributes only these are
the attributes
// that will be displayed in the search results.
outputAttributes = new String[classCount];
outputAttributes[ALL] =
"number name versionDisplayIdentifier displayType lifeCycleState projectId
modifyTimestamp";
outputAttributes[WTPART] =
"number name versionDisplayIdentifier projectId lifeCycleState
modifyTimestamp";

outputProcessing[MYCLASS] =
"ObjProps 0";
// **New for 6.0
// **Customize This is similar in concept to outputAttributes only this list
is used
// to indicate which attributes can be sorted, can't be sorted, or an alternate
attribute
// that can be sorted to have the same affect as the display attribute. The
string that is used
// here should be the column descriptor so that it can be used to create the
ClassAttribute for
// the query. The query that is used for search is a simple query that will
not sort on all
// of the display attributes. Changing the 0 to 1 for an unsupported attribute
will
// either cause exceptions or sorts that don't work. Attributes of the
following types are
// just some examples of the attributes that will either throw exceptions or
sort incorrectly:
// EnumeratedType, CabinetReference, DataFormatReference,
LifeCycleTemplateReference, ProjectReference,
// and ViewReference.
sortAttributes = new String[classCount];
sortAttributes[ALL] =
"1 1 versionInfo.identifier.versionId 0 0 01";
sortAttributes[WTPART] =
"1 1 versionInfo.identifier.versionId 0 0 1";

sortAttributes[MYCLASS] =
"1 1";
// **New for 6.0
// **Customize This is similar in concept to outputAttributes only this list
is used
// for assigning a unique key to the sort preferences for this search. This
string will
// be persisted and used to retrieve the sort preferences for users. If the
value of one
// of these strings is changed or deleted after the system is in operation it
will create orphaned
// preferences in the system and users will lose the value that they had
persisted for that
// search. New entries can be added when a new search is added so that sort
preferences
// can be saved for that new search. These strings are arbitrary and never
displayed to the user.
sortPref = new String[classCount];
sortPref[ALL] =
"all";
sortPref[WTPART] =
"wtpart";

sortPref[MYCLASS] =
"myclass";
}
/**
*
* <BR><BR><B> Supported API: </B>false
*
* @param locale
* @return MySearchAttributeList
**/
public MySearchAttributeList( Locale locale ) {
setLocale(locale);
}
/**
*
* <BR><BR><B> Supported API: </B>false
*
* @return MySearchAttributeList
**/
public MySearchAttributeList() {
return;
}
}
wt.query.SearchAttributeList è sempre il più aggiornato e deve essere utilizzato come riferimento.
Nella parte rimanente di questa sezione vengono illustrati due nuovi array di wt.query.SearchAttributeList: sortAttributes e sortPref.
A causa della struttura di dati utilizzata per alcune classi, non tutti gli attributi che possono essere visualizzati nei risultati della ricerca possono essere ordinati. Per specificare gli attributi che è possibile ordinare e per indicare se è necessario utilizzare un attributo alternativo per stabilire l'ordinamento, viene utilizzato l'array sortAttributes in wt.query.SearchAttributeList. Un esempio di attributo alternativo utilizzato per l'ordinamento è l'attributo di versione. L'attributo utilizzato per la visualizzazione è versionDisplayIdentifier, mentre l'attributo utilizzato per l'ordinamento è versionInfo.identifier.versionId. I tipi Java di base, ad esempio String e int, sono ordinabili. Utilizzare gli esempi in wt.query.SearchAttributeList per definire se eventuali tipi personalizzati sono ordinabili. In caso contrario, un semplice test indica se l'attributo funziona, non ha alcun effetto oppure genera un'eccezione.
L'array sortPref (illustrato nel codice precedente) viene utilizzato per definire un nome base per le preferenze di ordinamento in modo da consentire agli utenti di specificare le preferenze di ordinamento relativamente all'oggetto "Chiave di ricerca" in questione. È necessario definire un valore di default per le preferenze di ordinamento a livello di sistema in modo che la prima volta che l'utente utilizza il sistema, o se un utente non definisce mai le proprie preferenze, le colonne vengano ordinate secondo un ordine logico. Per definire un valore di default, è possibile utilizzare wt.load.LoadFromFile oppure l'editor Amministrazione preferenze dalla pagina del portale dell'amministratore di sistema.
Se si tratta di un nuovo database, i valori di default vengono caricati come parte dell'esecuzione della sezione richiesta di wt.load.Demo (che esegue wt.load.LoadFromFile). È possibile aggiungere o modificare facilmente i valori di default del sito mediante l'Amministrazione preferenze. Se il database è stato creato in un sistema precedente alla release 6.0, è possibile utilizzare wt.load.LoadFromFile per il caricamento dei valori di default di base per la configurazione fornita delle classi di ricerca HTML. Vedere le voci "PrefEntry…/wt/query/htmlsearch" in Windchill\loadFiles\preferences.txt come esempi.
Ogni preferenza utente presenta un nome interno che non è mai visibile al client, tranne che nell'Amministrazione preferenze. Dal momento che la ricerca corrente utilizza wt.query.SearchAttributeList per consentire agli utenti di aggiungere nuove ricerche e che per ognuna di queste deve essere presente un insieme di preferenze di ordinamento, è necessario un nome di ordinamento univoco per ciascun nome dell'elenco "Chiave di ricerca". Ogni oggetto dell'elenco "Chiave di ricerca" non è necessariamente costituito da un solo oggetto, bensì può essere costituito da un elenco di oggetti. L'array sortPref in wt.query.SearchAttributeList definisce una stringa univoca che costituisce parte del nome della preferenza. Le preferenze per l'ordinamento sono memorizzate nel nodo delle preferenze /wt/query/htmlsearch e il formato di denominazione è il seguente:
<nome base preferenze ordinamento>sortAttrib<n.>
<nome base preferenze ordinamento>sortDirect<n.>
Il <nome base preferenze ordinamento> è la stringa univoca dell'array sortPref in wt.query.SearchAttributeList. Tale stringa deve essere univoca solo all'interno dei nomi di ordinamento. sortAttrib rappresenta il nome dell'attributo, mentre sortDirect indica l'ordine crescente o decrescente. False determina l'ordine crescente, true quello decrescente. <n.> è il numero della chiave di ordinamento, 0 = prima chiave e così via. Di seguito sono illustrate le preferenze caricate mediante wt.load.LoadFromFile e Windchill\loadFiles\preferences.txt per l'ordinamento All:
#All
PrefEntry~allsortAttrib0~number~/wt/query/htmlsearch
PrefEntry~allsortDirect0~false~/wt/query/htmlsearch
PrefEntry~allsortAttrib1~versionInfo.identifier.versionId~/wt/query/htmlsearch
PrefEntry~allsortDirect1~true~/wt/query/htmlsearch
Nell'esempio i risultati vengono ordinati prima in base alla colonna numero, quindi in base alla colonna versione, con i numeri in ordine crescente e le versioni in ordine decrescente. Attualmente il numero di chiavi di ordinamento supportato è 3, sebbene in teoria il numero di chiavi di ordinamento sia limitato solo dalle prestazioni di Oracle. Nel sistema non sono state effettuate verifiche per un numero di chiavi superiore a 3.