I am newbie to mpngodb.
I have two collections.
Tenant
{
Tenant_ID:123, Tenant_Info:new
Tenant_ID:456, Tenant_Info:old
}
System
{
System_ID:768, Tenant_ID:123,System_Info:"check"
}
I need to reference the Tenant collection Tenant_ID with System collection Tenant_ID.
Could anyone help me with the DBREF java code for mongodb to achieve this relationship?
Database References (DBRefs) are used by convention; they do not correspond to a supported feature in the MongoDB server.
If you want to store a reference to another collection in your document you could do it a few ways:
1) Just save the relevant key for the other collection (in your example the Tenant_ID of the related Tenant document wants to be saved as a field in a document in the System collection).
2) Use the DBRef class to construct a reference to the object and then [fetch()](http://api.mongodb.org/java/current/com/mongodb/DBRef.html#fetch(com.mongodb.DB, com.mongodb.DBObject)) the referenced object.
Based on your example, it looks like the first usage would be more relevant - you appear to be saving the Tenant_ID field in your System document. In this case, you can load a System document and use findOne() to retrieve the related Tenant document based on the Tenant_ID (assuming Tenant_ID uniquely identifies a Tenant).
Take a look at Spring Data MongoDB.
Related
I'm developing a data project with ASP.NET Core and Entity Framework Core. We're starting to use user claims (Identity) to manage authorization for things like managers etc. Previously, we had a separate table for managers, so that each permission could be set on each object and we looked it up as required.
Simple example prior to UserClaims:
Store { StoreId, Name etc... plus ICollection<ManagerPermissions> }
User { StoreId, Name, Email etc}
ManagerPermissions { StoreId, UserId }
Using the separate ManagerPermissions table meant it was easy to list the relevant manager(s) for that store by using a navigation property like ICollection<ManagerPermissions>. If writing a query, I could do _context.Store.Include(s => s.ManagerPermissions) to include a list of managers to display.
Now that we're using user claims, I haven't found an easy way to do this. I've extended IdentityDbContext so the claims data is held within the same database as the other data.
I have seen
UserManager.GetUsersWithClaimAsync({ ClaimType="ismanager", ClaimValue = StoreId})
but this requires an instance of userManager and also a separate roundtrip to the database. The only other way I could think of is by doing a join on UserClaims table, but I'm not sure the most efficient way of doing this.
I want to update all the external ids of res.partner in system while creating partners using create() method. Also, I am not getting the functionality where the default external id name(res_partner_id) is generating.
Example :
Default generated external_id : res_partner_[id]
External id to be updated : abcd_res_partner_country_id_[id]
An External ID is an identifier for a data record. The mechanism behind this is quite simple: Odoo keeps a table with the mapping between the named External IDs and their corresponding numeric database IDs. That is the ir.model.data model.
To inspect the existing mappings, go to the Technical section of the Settings menu, and select the Sequences & Identifiers | External Identifiers menu item.
Recommended link: https://www.odoo.com/forum/help-1/question/how-to-update-external-id-50395
In my WebI Report I would like to print the Author or the Last modified User name.
How can I obtain it?
Have a look at the manual Using functions, formulas and calculations in Web Intelligence, which contains a reference information regarding functions you'd need to retrieve this information. You can find the manuals for your specific version of BusinessObjects on help.sap.com.
The functions you're probably looking for are DocumentOwner() and DocumentAuthor().
Update:
While you can't retrieve the user's full name in Web Intelligence, there is a workaround, provided that
You're using third-party authentication (e.g. Windows AD)
You're able to pull the full name from that source into the CMC
If so, you can use User Attribute Management to define a new user attribute in the CMC and then create a new dimension in your (UNX) universe which uses the #Variable to get in the new user attribute value.
From the IDT manual (paragraph 18.3.6 About #Variable, version BI 4.1 SP5):
To reference a User Attribute, specify the internal name for the at
tribute as it is defined in the CMC. #Variable returns the value of
the attribute for the current user. For example, the User Attribute
MYCOUNTRY contains the value of the country of each user in the CMC.
Specify the attribute's internal name surrounded by single quotes:
#Variable('SI_MYCOUNTRY')
The attribute’s internal name is defined when the attribute is cre ated in the CMC
User Attribute Management is described in the Administrator Guide, paragraph 6.2.17 Managing attributes for system users (version BI 4.1 SP5).
I am working to create a Java based RESTful API that uses Spring MVC.
Now for some of the API endpoints-- multiple different parameters are required... I am not talking about a list of values-- more like parameter1, parameter2, parameter3, parameter4 and so on-- where all the 4 (or more) parameters are of different data types as well.
How do I design the API endpoint URL for the above scenario, eg for 4 separate input parameters? Is there any recommended way/best practice for doing this? Or do I simply concatenate the 4 values, with ach pair of values separated by a delimiter like "/"?
EDIT from user comment:
Example: I have to retrieve a custom object(a 'file') based on 4 input parameters--(Integer) userid, (Integer) fileid, (String) type, and (String) usertype. Should I simply create a REST Endpoint like "getfile/{userid}/{fileid}/{type}/{usertype}-- or is there a better (or recommended way) to construct such REST endpoints?
In REST start by thinking about the resource and coming up with immutable permalinks (doesn't change)to identify that resource.
So, in your example (in comment), you said you want to retrieve a file resource for a user and type (file type or user type?)
So, start with just enough information to identify the resource. If the id is unique, then this is enough to identify the resource regardless of the user who owns the file:
/files/{fileId}
That's also important as the url if a file could change owners - remember we want to identify the resource with just the components needed so it can be a permalink.
You could also list the files for a specific user:
/users/{userId}/files/
The response would contain a list of files and each of those items in the list would contain links to the files (/files/{fileId})
If for some reason the file id is not unique but is unique only in the context of a user (files don't change owners and id increments within a user - wierd) then you would need these components to identify the resource:
/users/{userId}/files/{fileId}
Also note the order based on the description. In that wierd case, we said the files are logically contained and IDed by the user and that's also the containment in the url structure.
Hope that helps.
A GET request to file/{usertype}/{user}/{type}/{fileid} sounds good
I am attempting to create a new Case object using the REST API but need to find out how to format the JSON body to pass in nested SObjects.
It's not apparent in the Docs, and I can't seem to find any examples. Anyone have any pointers or have done this before?
The SF web UI uses a text lookup field to set the (related) Contact and Account, and I need to figure out how to either bypass the need for a lookup or embed the SObjects of the related records in the JSON.
[{"message":"The value provided for foreign key reference Contact is not a nested SObject","errorCode":"INVALID_FIELD"}]
Figured it out by simply setting the AccountId and ContactId attributes on the new Case object.
I also haven't seen any documentation about this, but if you look at the object metadata returned by the REST API for any standard object, it seems that the suffix 'Id' is appended to any field of type "reference". For example, Case has OwnerId, LastModifiedById, CreatedById, etc. This suffix is not present in the field names displayed in the browser interface. The WSDL for the SOAP API includes both the ID as a simple element of type "ID", as well as a complex child element for nesting the actual record.