Share Elements of a List in an Object among Objects like cloud storage (standard library)
class User{
private String Nickname;
private String password;
private ArrayList<E> userdata;
// methods
}
I have a lot of users, everyone with own "userdata".
I would allow a generic user "X" to access some elements of user "Y".
I did this:
class User{
private String Nickname;
private String password;
private ArrayList<E> userdata;
private ArrayList<E> data_shared_from_other_users_to_me;
// methods
}
If the user "Y" will be deleted, every data will be deleted with him, so I will be forced to scan every "User" which have elements of "Y" in his "data_shared_from_other_users_to_me" variable and than delete them.
Is there a better solution to allow sharing and in case of deletion of an user delete every shared data withot looking for them inside every user?
java object generics share
add a comment |
class User{
private String Nickname;
private String password;
private ArrayList<E> userdata;
// methods
}
I have a lot of users, everyone with own "userdata".
I would allow a generic user "X" to access some elements of user "Y".
I did this:
class User{
private String Nickname;
private String password;
private ArrayList<E> userdata;
private ArrayList<E> data_shared_from_other_users_to_me;
// methods
}
If the user "Y" will be deleted, every data will be deleted with him, so I will be forced to scan every "User" which have elements of "Y" in his "data_shared_from_other_users_to_me" variable and than delete them.
Is there a better solution to allow sharing and in case of deletion of an user delete every shared data withot looking for them inside every user?
java object generics share
It sounds like you want to re-invent a "database" ;)
– paulsm4
Nov 23 '18 at 0:59
@paulsm4 It's very difficult to explain well what I am looking for, but no, I don't want to create a database, or something difficult
– PiKort
Nov 23 '18 at 1:00
It's not "difficult". It sounds like it's probably "the correct design" :( But like anything, the "ideal solution" depends on tradeoffs, which in turn depend on the specific details of your specific "use case", or "requirements". And you haven't really told us anything about that yet...
– paulsm4
Nov 23 '18 at 1:05
@paulsm4 I have users, with files (userdata List). A user A can let other users to access some files, if A will be deleted in every user, files received from A will disappear and are not accessible anymore. In C it could be resolved using pointers
– PiKort
Nov 23 '18 at 1:17
Q: Have you considered storing the "files" as blobs in a database?
– paulsm4
Nov 23 '18 at 4:39
add a comment |
class User{
private String Nickname;
private String password;
private ArrayList<E> userdata;
// methods
}
I have a lot of users, everyone with own "userdata".
I would allow a generic user "X" to access some elements of user "Y".
I did this:
class User{
private String Nickname;
private String password;
private ArrayList<E> userdata;
private ArrayList<E> data_shared_from_other_users_to_me;
// methods
}
If the user "Y" will be deleted, every data will be deleted with him, so I will be forced to scan every "User" which have elements of "Y" in his "data_shared_from_other_users_to_me" variable and than delete them.
Is there a better solution to allow sharing and in case of deletion of an user delete every shared data withot looking for them inside every user?
java object generics share
class User{
private String Nickname;
private String password;
private ArrayList<E> userdata;
// methods
}
I have a lot of users, everyone with own "userdata".
I would allow a generic user "X" to access some elements of user "Y".
I did this:
class User{
private String Nickname;
private String password;
private ArrayList<E> userdata;
private ArrayList<E> data_shared_from_other_users_to_me;
// methods
}
If the user "Y" will be deleted, every data will be deleted with him, so I will be forced to scan every "User" which have elements of "Y" in his "data_shared_from_other_users_to_me" variable and than delete them.
Is there a better solution to allow sharing and in case of deletion of an user delete every shared data withot looking for them inside every user?
java object generics share
java object generics share
asked Nov 23 '18 at 0:56
PiKortPiKort
103
103
It sounds like you want to re-invent a "database" ;)
– paulsm4
Nov 23 '18 at 0:59
@paulsm4 It's very difficult to explain well what I am looking for, but no, I don't want to create a database, or something difficult
– PiKort
Nov 23 '18 at 1:00
It's not "difficult". It sounds like it's probably "the correct design" :( But like anything, the "ideal solution" depends on tradeoffs, which in turn depend on the specific details of your specific "use case", or "requirements". And you haven't really told us anything about that yet...
– paulsm4
Nov 23 '18 at 1:05
@paulsm4 I have users, with files (userdata List). A user A can let other users to access some files, if A will be deleted in every user, files received from A will disappear and are not accessible anymore. In C it could be resolved using pointers
– PiKort
Nov 23 '18 at 1:17
Q: Have you considered storing the "files" as blobs in a database?
– paulsm4
Nov 23 '18 at 4:39
add a comment |
It sounds like you want to re-invent a "database" ;)
– paulsm4
Nov 23 '18 at 0:59
@paulsm4 It's very difficult to explain well what I am looking for, but no, I don't want to create a database, or something difficult
– PiKort
Nov 23 '18 at 1:00
It's not "difficult". It sounds like it's probably "the correct design" :( But like anything, the "ideal solution" depends on tradeoffs, which in turn depend on the specific details of your specific "use case", or "requirements". And you haven't really told us anything about that yet...
– paulsm4
Nov 23 '18 at 1:05
@paulsm4 I have users, with files (userdata List). A user A can let other users to access some files, if A will be deleted in every user, files received from A will disappear and are not accessible anymore. In C it could be resolved using pointers
– PiKort
Nov 23 '18 at 1:17
Q: Have you considered storing the "files" as blobs in a database?
– paulsm4
Nov 23 '18 at 4:39
It sounds like you want to re-invent a "database" ;)
– paulsm4
Nov 23 '18 at 0:59
It sounds like you want to re-invent a "database" ;)
– paulsm4
Nov 23 '18 at 0:59
@paulsm4 It's very difficult to explain well what I am looking for, but no, I don't want to create a database, or something difficult
– PiKort
Nov 23 '18 at 1:00
@paulsm4 It's very difficult to explain well what I am looking for, but no, I don't want to create a database, or something difficult
– PiKort
Nov 23 '18 at 1:00
It's not "difficult". It sounds like it's probably "the correct design" :( But like anything, the "ideal solution" depends on tradeoffs, which in turn depend on the specific details of your specific "use case", or "requirements". And you haven't really told us anything about that yet...
– paulsm4
Nov 23 '18 at 1:05
It's not "difficult". It sounds like it's probably "the correct design" :( But like anything, the "ideal solution" depends on tradeoffs, which in turn depend on the specific details of your specific "use case", or "requirements". And you haven't really told us anything about that yet...
– paulsm4
Nov 23 '18 at 1:05
@paulsm4 I have users, with files (userdata List). A user A can let other users to access some files, if A will be deleted in every user, files received from A will disappear and are not accessible anymore. In C it could be resolved using pointers
– PiKort
Nov 23 '18 at 1:17
@paulsm4 I have users, with files (userdata List). A user A can let other users to access some files, if A will be deleted in every user, files received from A will disappear and are not accessible anymore. In C it could be resolved using pointers
– PiKort
Nov 23 '18 at 1:17
Q: Have you considered storing the "files" as blobs in a database?
– paulsm4
Nov 23 '18 at 4:39
Q: Have you considered storing the "files" as blobs in a database?
– paulsm4
Nov 23 '18 at 4:39
add a comment |
1 Answer
1
active
oldest
votes
- Add an embedded or standalone relative database and use many-to-many relations with cascade
- Implement many-to-many relations using 2 hash maps (
Map<SuperUser, List<ObservableUser>>
andMap<ObservableUser, List<SuperUser>>
). This will allow to retrieve user's shared data in O(1) and remove relations in one shot. - You can add a list of users who can view current user data (Superusers) to a user profile (my_data_is_shared_with - list) and iterate only them on profile deletion
- On user deletion make all his userdata = null first. Then implement a getter for a SuperUser that will return data_shared_from_other_users_to_me.stream().filter(Object::notNull).collect(toList()) and update it if modified (some null values are filtered out)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439525%2fshare-elements-of-a-list-in-an-object-among-objects-like-cloud-storage-standard%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
- Add an embedded or standalone relative database and use many-to-many relations with cascade
- Implement many-to-many relations using 2 hash maps (
Map<SuperUser, List<ObservableUser>>
andMap<ObservableUser, List<SuperUser>>
). This will allow to retrieve user's shared data in O(1) and remove relations in one shot. - You can add a list of users who can view current user data (Superusers) to a user profile (my_data_is_shared_with - list) and iterate only them on profile deletion
- On user deletion make all his userdata = null first. Then implement a getter for a SuperUser that will return data_shared_from_other_users_to_me.stream().filter(Object::notNull).collect(toList()) and update it if modified (some null values are filtered out)
add a comment |
- Add an embedded or standalone relative database and use many-to-many relations with cascade
- Implement many-to-many relations using 2 hash maps (
Map<SuperUser, List<ObservableUser>>
andMap<ObservableUser, List<SuperUser>>
). This will allow to retrieve user's shared data in O(1) and remove relations in one shot. - You can add a list of users who can view current user data (Superusers) to a user profile (my_data_is_shared_with - list) and iterate only them on profile deletion
- On user deletion make all his userdata = null first. Then implement a getter for a SuperUser that will return data_shared_from_other_users_to_me.stream().filter(Object::notNull).collect(toList()) and update it if modified (some null values are filtered out)
add a comment |
- Add an embedded or standalone relative database and use many-to-many relations with cascade
- Implement many-to-many relations using 2 hash maps (
Map<SuperUser, List<ObservableUser>>
andMap<ObservableUser, List<SuperUser>>
). This will allow to retrieve user's shared data in O(1) and remove relations in one shot. - You can add a list of users who can view current user data (Superusers) to a user profile (my_data_is_shared_with - list) and iterate only them on profile deletion
- On user deletion make all his userdata = null first. Then implement a getter for a SuperUser that will return data_shared_from_other_users_to_me.stream().filter(Object::notNull).collect(toList()) and update it if modified (some null values are filtered out)
- Add an embedded or standalone relative database and use many-to-many relations with cascade
- Implement many-to-many relations using 2 hash maps (
Map<SuperUser, List<ObservableUser>>
andMap<ObservableUser, List<SuperUser>>
). This will allow to retrieve user's shared data in O(1) and remove relations in one shot. - You can add a list of users who can view current user data (Superusers) to a user profile (my_data_is_shared_with - list) and iterate only them on profile deletion
- On user deletion make all his userdata = null first. Then implement a getter for a SuperUser that will return data_shared_from_other_users_to_me.stream().filter(Object::notNull).collect(toList()) and update it if modified (some null values are filtered out)
answered Nov 23 '18 at 5:27
AzeeAzee
1,4341219
1,4341219
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439525%2fshare-elements-of-a-list-in-an-object-among-objects-like-cloud-storage-standard%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It sounds like you want to re-invent a "database" ;)
– paulsm4
Nov 23 '18 at 0:59
@paulsm4 It's very difficult to explain well what I am looking for, but no, I don't want to create a database, or something difficult
– PiKort
Nov 23 '18 at 1:00
It's not "difficult". It sounds like it's probably "the correct design" :( But like anything, the "ideal solution" depends on tradeoffs, which in turn depend on the specific details of your specific "use case", or "requirements". And you haven't really told us anything about that yet...
– paulsm4
Nov 23 '18 at 1:05
@paulsm4 I have users, with files (userdata List). A user A can let other users to access some files, if A will be deleted in every user, files received from A will disappear and are not accessible anymore. In C it could be resolved using pointers
– PiKort
Nov 23 '18 at 1:17
Q: Have you considered storing the "files" as blobs in a database?
– paulsm4
Nov 23 '18 at 4:39