Script to iterate over sitestore
Author: tkuehl
Publication Date: 8/19/2010 10:23
Hi!
Is there any script or part of scripts that let me iterate over the sitestore to find an known attribute?
I would like to search for parameters used in a database query. As a result I need a list of all pages that use this parameter.
Best regards,
Torsten Kühl
Tags: attribute, database, iterate, parameter, query, sitestore, store
0
-
Author: gockel - 8/19/2010 10:44
Hi,
i would prefer to use the reference graph information to avoid iteration over the sitestore.
import de.espirit.firstspirit.access.store.Store;
import de.espirit.firstspirit.access.store.sitestore.PageRef;
import de.espirit.firstspirit.access.store.templatestore.Query;
import de.espirit.firstspirit.access.ReferenceEntry;
// UID of the query
QUERY_UID = "Products.products_1";
templateStore = context.getUserService().getStore(Store.Type.TEMPLATESTORE, false);
query = templateStore.getStoreElement(QUERY_UID, Query.UID_TYPE);
if (query == null) {
context.logError("query not found");
return;
}
// find all objects using the query
incomingRefs = query.getIncomingReferences();
for (ref : incomingRefs) {
// is it a sitestore reference
if (ref.isType(ReferenceEntry.SITE_STORE_REFERENCE)) {
element = ref.getReferencedElement();
if (element != null && element instanceof PageRef) {
cParams = element.getContent2Params();
if (cParams != null) {
catParam = cParams.getFilterParams().get("category");
if (catParam != null && catParam.equals(1088)) {
context.logInfo("pageref found - " + element.getUid() + "(ID=" + element.getId() + ")");
}
}
}
}
}0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
1 Kommentar