Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetDocumentByQualification not working #9

Open
xingying18 opened this issue Sep 12, 2018 · 4 comments
Open

GetDocumentByQualification not working #9

xingying18 opened this issue Sep 12, 2018 · 4 comments

Comments

@xingying18
Copy link

xingying18 commented Sep 12, 2018

First of all I want to say a big thank you for sharing your code.

I added the RestClient to my vs project (with content server and Rest version 7.1), the GetDocumentByQualification or GetObjectByQualification do not work. After adding some debug lines, i found out that the "links" in "feed" is empty, would appreciate if this can be fixed or provide the right way to use it.

I defined the option as the following:

FeedGetOptions DEFAULT_OPTIONS { get { return new FeedGetOptions { Inline = true, Links = true }; } }

And called the GetDocumentByQulification as the following:

RestRepository.GetDocumentByQualification("custom_document where i_latest_flag=1 and i_chronicle_id='" + ChronicleId + "'", DEFAULT_OPTIONS);

In the RepositoryExec.GetObjectByQualification function:

Feed feed = ExecuteDQL(dql, new FeedGetOptions { Inline = true });

The "entries[0]" in the "feed" does not contain any links:

2018-09-12 17:28:51,853 [1] DEBUG Emc.Documentum.Rest.DataModel.Repository -
{
"id": "https://xxx:8899/rest/repositories/myrep",
"title": "DQL query results",
"updated": "2018-09-12T17:28:51.811-04:00",
"total": 0,
"items-per-page": 0,
"page": 0,
"author": [
{
"name": "EMC Documentum"
}
],
"entries": [
{
"id": "https://xxx:8899/rest/repositories/myrep?inline=True&links=True&page=1&include-total=False&dql=select%20r_object_id%20from%20custom_document%20where%20i_latest_flag=1%20and%20i_chronicle_id='09031d4580be05cc'&index=0",
"title": "09031d4580be05cc",
"updated": "2018-09-12T17:28:51.811-04:00",
"author": [],
"content": {
"name": "query-result",
"properties": {
"r_object_id": "09031d4580be05cc"
}
},
"score": 0.0
}
],
"links": [
{
"rel": "self",
"href": "https://xxx:8899/rest/repositories/myrep?inline=True&links=True&page=1&include-total=False&dql=select%20r_object_id%20from%20custom_document%20where%20i_latest_flag=1%20and%20i_chronicle_id='09031d4580be05cc'"
}
]
}

@lili6561
Copy link
Collaborator

Hi,
As I could not reproduce your issue in REST 7.3 or 16.4, I give you below tips:
(1) From your above response, the entries[0] in the 'feed' do HAVE links, but only contain one 'self' link, and in the function RepositoryExec.GetObjectByQualification(), it wants to use the 'edit' link to access the entry, so you could update this method to use the 'self' like, this function should look like this:
public T GetObjectByQualification(string dql, SingleGetOptions options)
{
dql = "select r_object_id from " + dql;
Feed feed = ExecuteDQL(dql, new FeedGetOptions { Inline = false});
if (feed.Entries == null || feed.Entries.Count == 0)
{
return default(T);
}
if (feed.Entries.Count > 1)
{
throw new Exception("The qualification '" + dql + "' has more than one object in repository.");
}
// update the link rel from LinkRelations.EDIT.Rel to LinkRelations.SELF.Rel
return Client.GetSingleton(feed.Entries[0].Links, LinkRelations.SELF.Rel, options);
}
(2) BTW, this function support SingleGetOptions NOT FeedGetOptions.

@xingying18
Copy link
Author

Thank you for the reply. It has little to do with "LinkRelations.SELF.Rel" or "LinkRelations.EDIT.Rel", the problem is that "feed.Entries[0].Links" is empty. The following is the feed.ToString() (i reverted back to your original code):

2018-09-17 13:22:41,884 [1] DEBUG Emc.Documentum.Rest.DataModel.Repository - {
"id": "https://:8888/rest/repositories/",
"title": "DQL query results",
"updated": "2018-09-17T13:22:41.616-04:00",
"total": 0,
"items-per-page": 0,
"page": 0,
"author": [
{
"name": "EMC Documentum"
}
],
"entries": [
{
"id": "https://:8888/rest/repositories/?inline=True&links=True&page=1&include-total=False&dql=select%20r_object_id%20from%20dm_sysobject%20where%20r_object_id='09031d4580be05cc'&index=0",
"title": "09031d4580be05cc",
"updated": "2018-09-17T13:22:41.616-04:00",
"author": [],
"content": {
"name": "query-result",
"properties": {
"r_object_id": "09031d4580be05cc"
}
},
"score": 0.0
}
],
"links": [
{
"rel": "self",
"href": "https://:8888/rest/repositories/?inline=True&links=True&page=1&include-total=False&dql=select%20r_object_id%20from%20dm_sysobject%20where%20r_object_id='09031d4580be05cc'"
}
]
}

@lili6561
Copy link
Collaborator

Hi,
Based on your above comment, the feed.Entries[0].Links should be :
"links": [
{
"rel": "self",
"href": "https://:8888/rest/repositories/?inline=True&links=True&page=1&include-total=False&dql=select%20r_object_id%20from%20dm_sysobject%20where%20r_object_id='09031d4580be05cc'"
}
]
.....

@xingying18
Copy link
Author

xingying18 commented Sep 18, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants