I would like to search for a text in an attribute of UCM content using RIDC. If I use GET_SEARCH_RESULTS service, I will be getting only the latest revision the of result document. But I want to get all the revisions, which will fall in to the given search criteria. is there any way for the same?
Sample code is here..
String whereClause = "UPPER(XCOMMENTS) LIKE '%VALUE%'";
dataBinder.putLocal("IdcService", "GET_DATARESULTSET");
dataBinder.putLocal("dataSource", "Documents");
dataBinder.putLocal("whereClause", whereClause);
dataBinder.putLocal("resultName", "YourResult");
ServiceResponse response =
idcClient.sendRequest(userContext, dataBinder);
System.out.println(response.toString());
DataBinder serverBinder = response.getResponseAsBinder();
DataResultSet resultSet = serverBinder.getResultSet("YourResult");
Do you want to search for against full-text or metadata?
If metadata, you should be able to use service GET_DATARESULTSET and dataSource RevisionIDs.
If full-text, you might need to roll your own.
Related
I'm fairly new too and struggling with OpenXML. We basically have a Word template and depending on the number of records the user selects in a website we have, we pull the records out of the database and use the template to create a word document. Then we assemble all these documents into one master Word document which is served up to the user. We use OpenXML and altchunks to do this:
string altChunkId = "AltChunkId" + itemNo.ToString();
MainDocumentPart mainPart = myDoc.MainDocumentPart;
AlternativeFormatImportPart chunk = mainPart.AddAlternativeFormatImportPart( AlternativeFormatImportPartType.WordprocessingML, altChunkId);
using (FileStream fileStream = File.Open(createdFileName, FileMode.Open))
{
chunk.FeedData(fileStream);
fileStream.Close();
}
AltChunk altChunk = new AltChunk();
AltChunkProperties altChunkProperties = new AltChunkProperties();
MatchSource matchSrc = new MatchSource();
matchSrc.Val = true;
altChunkProperties.Append(matchSrc);
altChunk.AppendChild(altChunkProperties);
altChunk.Id = altChunkId;
mainPart.Document.Body.Append(altChunk);
mainPart.Document.Save();
When I open one of the template documents in the Productivity tool I can see all the elements which I'd expect:
However, when I look at the 'master' document, all I can get down to is the MatchSource:
What I don't understand is why I can't see the paragraph tags etc in the master document that's produced. Can anybody help me understand how I would see this information? Is there something wrong with the document structure?
That's because of the way altchunks are merged to the master document. altchunks won't change the master document's openxml markup but it does add the file as embedded resources. Think of it as if you are attaching something to an email but not adding it to the actual email body text. There are some third party solutions like Document Builder that will merge the document by modifying the master documents markup. Then you can see what you are expecting in the productivity tool.
I am using Tastypie, Django for my project.
To Update a many to many field I have used save_m2m hook.
def save_m2m(self, bundle):
for field_name, field_object in self.fields.items():
if not getattr(field_object, 'is_m2m', False):
continue
if not field_object.attribute:
continue
if field_object.readonly:
continue
related_mngr = getattr(bundle.obj, field_object.attribute)
related_objs = []
print bundle.data[field_name]
for related_bundle in bundle.data[field_name]:
try:
stock = Stock.objects.get(nse_symbol = related_bundle.obj.nse_symbol)
print stock.__dict__
except Stock.DoesNotExist as e:
dataa = {"error_message": e}
raise ImmediateHttpResponse(response=HttpBadRequest(content=json.dumps(dataa), content_type="application/json; charset=UTF-8"))
related_objs.append(stock)
related_mngr.add(*related_objs)
Now I want to remove elements from the same many to many field.
How should I achieve this. Do I have to send a patch request or delete request and how to handle this.
I am begineer in tastypie. I googled it some time and I couldn't find a proper way. Please guide me how to complete this.
Thanks.
I've thought a lot about handing m2m relationships, since most of our app depends on m2m links.
I've settled for the approach of an update method. Pass in the all the references of the relationships you want changed (add and remove), then update the db accordingly. We only pass in the changed values, since if you have a paginated list, you only want to update the items the user has identified. Generally I use a custom hook for this defined in override_urls.
I used to have a separate add and remove method, which worked well until we changed the gui and allowed users simply to change checkboxes. In that approach having an update method was much more useful. You'll have to decide on which method suits your application the best.
I am getting files from Oracle UCM via RIDC. I am using DataBinder as follows :
IdcClient client =getUCMConnection();
DataBinder dataBinder = client.createBinder ();
dataBinder.putLocal ("IdcService", "GET_FILE");
dataBinder.putLocal ("dID", dID);
IdcContext userContext = new IdcContext(username);
ServiceResponse response = client.sendRequest (userContext, dataBinder);
InputStream fstream = response.getResponseStream ();
....... etc.
I want to ask, how can I get "ALL VERSIONS" of a document instead of latest released one?
First you have to call the service DOC_INFO, you can get the result set of the revision by using the REVISION_HISTORY set.
You will get specific dID for each version, you iterate them and use GET_FILE with dID as a parameter for each one of them
I can't test it right now but I think the service you are looking for is GET_INFO, try it and check all the resultsets you get I'm pretty sure one of them has the info for all the document's revisions.
You can use the service REV_HISTORY to get the result set REVISIONS which contains info of all the revisions.
I would like to view the custom metadata that I associated with the my custom document, that I created with the document library, anyone know how to due with velocity variable?
Thanks in advance
Sabrina
You can get some meta-data articles properties with
$reserved-article-id.data
$reserved-article-title.data
full list you can find here
Also you can check this post, it has example how to get journal's categories at velocity template.
UPD. For getting document metadata you can use smth like this:
#set($dlFileUtil = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService"))
#set ($groupId = $getterUtil.getLong($groupId))
#set($fileEntry = $dlFileEntryUtil.getFileEntryByUuidAndGroupId($uuid,$longGroupId))
#set($metadataUtil=$serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryMetadataLocalService"))
You can use getFileEntryMetadata(ddmStructureId, fileVersionId) from $metadataUtil
More detailed code you can check this.
BR,
Paul Butenko
I have at the welcome page a weather portlet, and user can configure the portlet and select his city. Is it possible to store user information in the portlet preferences, so that every user has his one stored city? Or what is the standard workflow to store user-portlet information without to develop own (persist) service?
thx
The portlet-preferences are in liferay per default not user specific. That can be modified in liferay-portlet.xml with next lines:
<liferay-portlet-app>
<portlet>
<portlet-name>ThePortletWitchUserSpecificPreferences</portlet-name>
<icon>/icon.png</icon>
<preferences-unique-per-layout>false</preferences-unique-per-layout>
<preferences-owned-by-group>false</preferences-owned-by-group>
</portlet>
...
</liferay-portlet-app>
the two lines <preferences-... and the order are abbreviated.
for more information see:
http://rutvijshah.wordpress.com/2009/12/06/user-specific-preferences-in-liferay/
It's not a native function of the PortletPreference : the setValue method allow only a String, unfortunately you can't pass a Map.
However, i see a solution to hardcode it, but it's a little bit ugly...
Long userId = ...... ;
String userValue = ..... ;
PortletPreferences prefs = request.getPreferences();
prefs.setValue("myConfig-"+userId, myUserVal);
prefs.store();
And for retrieve the data :
String userValue = prefs.getValue("myConfig-"+userId, defaultValue);
This solution will work, but don't do that is you have a big numbers of users.
Portlet Preferences are save in xml in your database, if you have 100k+ users, it will explode :)
If you think this solution is not enough clean, you will have to create your own persistence method with the ServiceBuilder.