Extensis Logo SUPPORT | FORUMS | KNOWLEDGE BASE

Trying to get a list of Item Ids


#1

Using Java I am trying to get a list of Item Ids that start with a certain number. So far I have been able to search on the RID and bring back a list of those but, the user doesn’t see that number when they look at the catalog through the portfolio application or netpublish page. They see Item ID. Also we have been using Item ID as our way of referencing a portfolio record for many years now it would be difficult to change to RID.
We work on a private network that doesn’t have internet access so I’ll have to give a little piece of my code.
Hopefully all I need is the appropriate field name to replace “ID??”. But if this code seems way off please let me know.

qTerm.setFieldName(“ID??”);
qTerm.setOperator(QueryOperator.STARTS_WITH_VALUE);
qTerm.getValues().add(obj.getStart());
assetQuery.setQueryTerm(qTerm);
resultOptions.setPageSize(250);
resultOptions.getFieldNames().add(“ID??”);
resultOptions.getFeildNames().add(other identifying fields)

AssetQueryResults AssetResults = service.getAssets(sessionId, catalogs.get(0).getCatalogId(), assetQuery, resultOptions);

for(Asset asset : AssetResults.getAssets()){
DTO obj2 = new DTO();
obj2.setRecordId(getAttributeValue(“ID??”, asset));
results.add(obj2);
}
service.logout(sessionId)
return results;


#2

I found part of the answer.
To list the Item ID you use asset.getAssetId() in your AssetResults for loop.

I still am not sure how to get the API to do a “STARTS_WITH_VALUE” search on the Item ID or assetId field.


#3

Hello,

I don’t believe you can directly query for asset IDs after a certain one, but you can query for an asset ID, get the cataloged date and then query for assets cataloged on or after that date. Since asset IDs are assigned in increasing order as items are cataloged that should give you what you want. Following is some sample code. Please let me know if you have any further questions.

Regards,
Mike

[code]AssetQueryTerm aqt = new AssetQueryTerm();
aqt.setOperator(QueryOperator.ASSETS_BY_ID);
aqt.getValues().add(YOUR_ASSET_ID_HERE);
AssetQuery query = new AssetQuery();
query.setQueryTerm(aqt);

AssetQueryResultOptions resultOptions = new AssetQueryResultOptions();
resultOptions.getFieldNames().add(“Cataloged”);
resultOptions.setPageSize(9999);
resultOptions.setStartingIndex(0);

AssetQueryResults results = assetService.getAssets(identitySession, testCatalog.getCatalogId(), query, resultOptions);

String catalogedDate = null;
if (results.getAssets().size() > 0) {
Asset asset = results.getAssets().get(0);
List attributes = asset.getAttributes();
if (attributes != null) {
for (MultiValuedAttribute mva : attributes) {
if (mva.getName().equals(“Cataloged”)) {
catalogedDate = mva.getValues().get(0);
break;
}
}
}
}

if (catalogedDate != null) {
aqt = new AssetQueryTerm();
aqt.setOperator(QueryOperator.GREATER_THAN_OR_EQUAL_VALUE);
aqt.setFieldName(“Cataloged”);
aqt.getValues().add(catalogedDate);

query = new AssetQuery();
query.setQueryTerm(aqt);

SortOptions sortOptions = new SortOptions();
sortOptions.setSortFieldName(“Cataloged”);
sortOptions.setSortOrderAscending(true);
query.setSortOptions(sortOptions);

resultOptions = new AssetQueryResultOptions();
resultOptions.getFieldNames().add(“Filename”);
resultOptions.getFieldNames().add(“Cataloged”);

results = assetService.getAssets(identitySession, testCatalog.getCatalogId(), query, resultOptions);
for (Asset asset : results.getAssets()) {
/* … */
}
}
[/code]


#4

Thank you for answering so quickly
The user expectation was they would enter 6 and get back a list containing 6, 60-69,600-699 ect.

They have decided that we can use one of the custom fields to do the search and they will select from the ids that come back on that.

Thank you for your help.