Integer previousContentId = new Integer(-1);
Integer previousLanguageId = new Integer(-1);
int currentCount = 0;
while(results.hasMore() && currentCount < maxRows)
{
ContentVersion contentVersion = (ContentVersion)results.next();
logger.info("Found a version matching " + searchString + ":" + contentVersion.getId() + "=" + contentVersion.getOwningContent().getName());
if(contentVersion.getOwningContent().getId().intValue() != previousContentId.intValue() || contentVersion.getLanguage().getId().intValue() != previousLanguageId.intValue())
{
ContentVersion latestContentVersion = ContentVersionController.getContentVersionController().getLatestActiveContentVersion(contentVersion.getOwningContent().getId(), contentVersion.getLanguage().getId(), db);
if(latestContentVersion.getId().intValue() == contentVersion.getId().intValue() && (caseSensitive == null || contentVersion.getVersionValue().indexOf(searchString) > -1))
{
if(!searchAssets || (contentVersion.getDigitalAssets() != null && contentVersion.getDigitalAssets().size() > 0))
{
matchingContents.add(contentVersion.getValueObject());
previousContentId = contentVersion.getOwningContent().getId();
previousLanguageId = contentVersion.getLanguage().getId();
currentCount++;
}
}
}
}
results.close();
oql.close();
if(searchAssets)
{
String assetSQL = "SELECT da FROM org.infoglue.cms.entities.content.impl.simple.SmallDigitalAssetImpl da WHERE (da.assetKey LIKE $1 OR da.assetFileName LIKE $2) ORDER BY da.digitalAssetId asc";
logger.info("assetSQL:" + assetSQL);
OQLQuery assetOQL = db.getOQLQuery(assetSQL);
assetOQL.bind("%" + searchString + "%");
assetOQL.bind("%" + searchString + "%");
QueryResults assetResults = assetOQL.execute(Database.READONLY);
previousContentId = new Integer(-1);
previousLanguageId = new Integer(-1);
currentCount = 0;
while(assetResults.hasMore() && currentCount < maxRows)
{
SmallDigitalAssetImpl smallAsset = (SmallDigitalAssetImpl)assetResults.next();
DigitalAsset asset = DigitalAssetController.getMediumDigitalAssetWithId(smallAsset.getId(), db);
logger.info("Found a asset matching " + searchString + ":" + asset.getId());
Collection versions = asset.getContentVersions();
Iterator versionsIterator = versions.iterator();
while(versionsIterator.hasNext())
{
ContentVersion contentVersion = (ContentVersion)versionsIterator.next();
if(contentVersion.getOwningContent().getId().intValue() != previousContentId.intValue() || contentVersion.getLanguage().getId().intValue() != previousLanguageId.intValue())
{
ContentVersion latestContentVersion = ContentVersionController.getContentVersionController().getLatestActiveContentVersion(contentVersion.getOwningContent().getId(), contentVersion.getLanguage().getId(), db);
if(latestContentVersion.getId().intValue() == contentVersion.getId().intValue() && (caseSensitive == null || contentVersion.getVersionValue().indexOf(searchString) > -1))
{
matchingContents.add(contentVersion.getValueObject());
previousContentId = contentVersion.getOwningContent().getId();
previousLanguageId = contentVersion.getLanguage().getId();
currentCount++;