0
  1. My video will be published in all or any one or any two or any three of the below departments like

    Test1,Test2,Test3,Test4 etc...

  2. Programmatically I will fetch all the department names for my video and constructed as Java StringBuilder as below:

    Test1,Test2,Test3,Test4 etc.

  3. These departments has privacy values of one of the below enum constants: PUBLIC,PROTECTED,PRIVATE.

  4. If my department is public then video privacy is public.

  5. If my department is protected then video privacy is protected.
  6. If my department is private then video privacy is private.

I can set video privacy as specified above if my video is published in single department. But if my video is published in more than one department and then one department privacy is public another department privacy is protected then I need to set it as protected considering the highest value.

How to manage all these conditions like:

  1. If privacy is public, private, protected then set video privacy as private
  2. If privacy is public, public, protected then set video privacy as protected like these combinations

Here is the code which gets all ids and privacies

List<Integer> newdepList = new ArrayList<Integer>();
    if(depName != null) {
        mediaVO.setDepNames(depName.toString());
        StringTokenizer st1 = new StringTokenizer(depName.toString(),",");
            if(depName.toString().contains(",")) {
                System.out.println("Media is assigned to more than one dep" + depName );
                while(st1.hasMoreTokens()) {
                    depname= st1.nextToken();
                    System.out.println("depname"+depname);
                    if(depname!= null) {
                    ListResponse resp = fetchDepDetails(depname);
                        if(resp.totalCount >= 1) {
                            for(Department dep:resp.objects) {
                                int rootdepId = Integer.valueOf(properties.getProperty("dep.id"));
                                if(dep.parentId == rootdepid|| dep.id == rootdepId) {
                                    newdepList.add(dep.id);
                                    //System.out.println("Department Id :::::::"+dep.id);
                                    //PrivacyType pri = fetchDepPrivacy(dep.id);
                                    //System.out.println("Privacy for the retrieved channels ----->"+pri);
                                }
                            }
                        }
                    }
                }

Thanks in advance, Sakuntala

Sakuntala
  • 1
  • 2
  • You need to have a folr loop and pass your token there. – Suresh Atta Apr 26 '16 at 14:17
  • @Suresh - Correct. But if my video is published in one department, then its correct. But if the departments are like test1,test2,test3 with privacy values like public,private,protected ...how to set video privacy in this scenario like the highest private as privacy? – Sakuntala Apr 26 '16 at 14:27

1 Answers1

1

maybe it makes sense to have your Visibility in an enum, where you can utilize the .ordinal() of each enum value? then if you have a list of departments departments.stream().map(d -> d.visivility().ordinal()).min().get()

and use Visibility.values()[i] in a convinient way around/inside the stream

best atanas