Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hello everyone,
I concern about a problem with the matching between user and Thing in Thingworx (For example: SIM/card management). Because the connection between user and Thing is one to one, so in the case there are a lot of things (e.g. 100 000 sim cards), then, I need to create 100 000 users and assign each thing to each user to ensure that other user can't see other thing in the Mashup. Hence, that is not a good ideal to do this because I need a lot of efforts to manage the users. I also think an other solution, that means create an unique "host" user in Thingworx for all user and an other database to store the user. When user login, I will authenticate with the database (use database extension) and if success, use the appKey of "host" user to load the mashup corresponding to the Thing connected to user (create a property named "username" and filter Thing by this property). But with this solution, I need to synchronous the appKey between Thingworx and my application. If the appKey is changed, I need to think far-away how to tell my app. Therefore, I am not sure it is an appropriate solution for my case or not. Are there anyone who have a similar use case with me ? I hope someone can share your experiments for this use case.
Also, because of the numerous connections can connect to the Platform by user, do you have the scalability for the web-service of Thingworx mashup ?
Solved! Go to Solution.
You can have different approaches to recover User's Thing if it's just one thing, here to sample approaches:
You can use Visibility instead for show/hide of Things to users.
Hi PaiChung,
I don't get your ideal. I know the "Visibility" in "Permissions" option but in the first case as I mentioned in my question, if I create one user per one device, the number of user is huge. I can't create each Thing and assign each "Visibility" for user (I can't use user group in this case because I don't want other people, who is not owner of thing see this information. My case is mapping one to one, that means one Thing is belongs to one people and when user login, they can view only Thing which is assigned to them). Then, that is why I post my problem, because when I learn the course in PTC university, the problem is numerous devices (Things) but a few users in Thingworx. Hence, there are no difficulty to think about user management. But now, when I am in the face of problem which need mapping one user to one thing, I didn't find any suitable design of Thingworx for this case.
I don't know where it's the difficulty with one thing one user and one visibility per user? you can automate everything. The only problem will be the load to the server but not automating thing/user creation.
Hello Carles,
The first thing is that the "Visibility" permission is applied only for "Organization" level. How do you do to assign visibility per user ? My actual problem is when user log-in to application, the application need to load the mashup which contain only thing belongs to user (e.g SIM card is a Thing, when user login, user can see only information concern about the sim owned by user, other user can't see this information). The thing/user creation does not need to automating because it requires specified information to fill, but, when you assign "Run time" permission or some permission to view the owned thing, it is not effective if you do drap/drop manually for 100 000 Thing. It lost the time and a lot of efforts to manage mapping between user and Thing if there are some changes such as change user per thing.
You can create a visibility Organizational Unit for each Thing, something like:
Things:
-------
Thing1
Thing2
Thing3
....
Organizational Unit User
--------------------- -----
| - Thing1 for User1 ThingsOU -- | - Thing2 for User2 | - Thing3 for User3 | - ....
You assign visibility ThingsOU:Thing1 to Thing1, and User1 to ThingsOU:Thing1 and you are done with visibility.
To to the previous structure on automated way, you just need to leverage ThingWorx scripting features with services like:
// -- Add OU for Thing1 Organizations["ThingsOU"].AddOrganizationalUnit({ parentName: "ThingsOU", name: "Thing1" }); // -- Add User1 to Thing1 OU Organizations["ThingsOU"].AddMember( { name: "Thing1", member: "User1", type: "User" }); // -- Add Visibility to Thing1 Things["Thing1"].AddVisibilityPermission({ principal: "ThingsOU:Thing1", principalType: "OrganizationalUnit" });
Dear Carles,
It is very helpful to mapping with the script to mapping between User and Thing. But, actually, when you log-in with user and password, how can you tell Thingworx to load the mashup contains only information of Thing mapping to user ? (I suppose that there is only one mashup for all thing)
You should build the Mashup based on ThingTemplate or ThingShape services and bind the User thing as to EntityName, you can use a HelperThing which returns User Own Thing
I'm confusing a little bit. When I login (such as /Thingworx/FormLogin) successfully, I will go to a Home mashup. As you mentioned, this mashup is created based on Thing Template. But I need to detect which Thing (to get the EntityName for mashup) from the user login. It is different when you use "HelperThing" to get User, right ?
You can have different approaches to recover User's Thing if it's just one thing, here to sample approaches:
Thank you for your response.
I totally understand your first approach and know it will work. I just want to know further about the second approach.
With the HelperThing, I aslo need to add a property as "ThingName" to the User Extentions, right ? Are there any ways to do this without adding property ?
Without adding the property, you can do a Search or alike, but I will "cache" the User thing on a property instead of doing a search each time..
Thank you Carles, I will mark your answer as solution
Hi Carles,
I just want to know a little bit about the architecture of Thingworx because before I create this post, I think about adding property to Thing and use "QueryImplementingThings" to find the user owned the Thing. Of course, this solution is worse than your solution. But I don't know "QueryImplementingThings" in service will be perform on application layer or database layer. Application layer means that Thingworx collects all data from database and filter and database layer means that Thingworx queries to database (e.g. ProsgresSQL, using SQL language). Because database is optimal for query, so, of course filter in database layer will be the best, but I don't know in this case, which layer will be used ?