6771 |
16 Mar 15 |
nicklas |
1 |
<%-- $Id$ |
6771 |
16 Mar 15 |
nicklas |
2 |
------------------------------------------------------------------ |
6771 |
16 Mar 15 |
nicklas |
Copyright (C) 2015 Nicklas Nordborg |
6771 |
16 Mar 15 |
nicklas |
4 |
|
6771 |
16 Mar 15 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
6771 |
16 Mar 15 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
6771 |
16 Mar 15 |
nicklas |
7 |
|
6771 |
16 Mar 15 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
6771 |
16 Mar 15 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
6771 |
16 Mar 15 |
nicklas |
10 |
as published by the Free Software Foundation; either version 3 |
6771 |
16 Mar 15 |
nicklas |
11 |
of the License, or (at your option) any later version. |
6771 |
16 Mar 15 |
nicklas |
12 |
|
6771 |
16 Mar 15 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
6771 |
16 Mar 15 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
6771 |
16 Mar 15 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6771 |
16 Mar 15 |
nicklas |
16 |
GNU General Public License for more details. |
6771 |
16 Mar 15 |
nicklas |
17 |
|
6771 |
16 Mar 15 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
6771 |
16 Mar 15 |
nicklas |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
6771 |
16 Mar 15 |
nicklas |
20 |
------------------------------------------------------------------ |
6771 |
16 Mar 15 |
nicklas |
21 |
|
6771 |
16 Mar 15 |
nicklas |
22 |
@author Nicklas |
6771 |
16 Mar 15 |
nicklas |
23 |
--%> |
6771 |
16 Mar 15 |
nicklas |
24 |
<%@ page pageEncoding="UTF-8" session="false" |
6771 |
16 Mar 15 |
nicklas |
25 |
import="net.sf.basedb.core.SessionControl" |
6771 |
16 Mar 15 |
nicklas |
26 |
import="net.sf.basedb.core.DbControl" |
6771 |
16 Mar 15 |
nicklas |
27 |
import="net.sf.basedb.core.Item" |
6771 |
16 Mar 15 |
nicklas |
28 |
import="net.sf.basedb.core.ItemContext" |
6927 |
04 Jun 15 |
nicklas |
29 |
import="net.sf.basedb.core.ItemQuery" |
6771 |
16 Mar 15 |
nicklas |
30 |
import="net.sf.basedb.core.Permission" |
6771 |
16 Mar 15 |
nicklas |
31 |
import="net.sf.basedb.core.ItemList" |
6771 |
16 Mar 15 |
nicklas |
32 |
import="net.sf.basedb.core.RawDataType" |
6771 |
16 Mar 15 |
nicklas |
33 |
import="net.sf.basedb.core.ItemSubtype" |
6771 |
16 Mar 15 |
nicklas |
34 |
import="net.sf.basedb.core.PermissionDeniedException" |
6771 |
16 Mar 15 |
nicklas |
35 |
import="net.sf.basedb.clients.web.Base" |
6771 |
16 Mar 15 |
nicklas |
36 |
import="net.sf.basedb.clients.web.util.HTML" |
6771 |
16 Mar 15 |
nicklas |
37 |
import="net.sf.basedb.util.Values" |
6771 |
16 Mar 15 |
nicklas |
38 |
import="java.util.List" |
6927 |
04 Jun 15 |
nicklas |
39 |
import="java.util.ArrayList" |
6927 |
04 Jun 15 |
nicklas |
40 |
import="java.util.Set" |
6927 |
04 Jun 15 |
nicklas |
41 |
import="java.util.HashSet" |
6771 |
16 Mar 15 |
nicklas |
42 |
%> |
6771 |
16 Mar 15 |
nicklas |
43 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
6771 |
16 Mar 15 |
nicklas |
44 |
<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
6771 |
16 Mar 15 |
nicklas |
45 |
<% |
6771 |
16 Mar 15 |
nicklas |
46 |
final Item itemType = Item.ITEMLIST; |
6771 |
16 Mar 15 |
nicklas |
47 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
6771 |
16 Mar 15 |
nicklas |
48 |
final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
6771 |
16 Mar 15 |
nicklas |
49 |
final int itemId = cc.getId(); |
6771 |
16 Mar 15 |
nicklas |
50 |
final String ID = sc.getId(); |
6771 |
16 Mar 15 |
nicklas |
51 |
final float scale = Base.getScale(sc); |
7954 |
12 May 21 |
nicklas |
52 |
final DbControl dc = sc.newDbControl(":Re-sync item lists"); |
6771 |
16 Mar 15 |
nicklas |
53 |
try |
6771 |
16 Mar 15 |
nicklas |
54 |
{ |
6771 |
16 Mar 15 |
nicklas |
55 |
ItemList itemList = ItemList.getById(dc, itemId); |
6771 |
16 Mar 15 |
nicklas |
56 |
String title = "Re-sync: " + HTML.encodeTags(itemList.getName()); |
6771 |
16 Mar 15 |
nicklas |
57 |
itemList.checkPermission(Permission.WRITE); |
6771 |
16 Mar 15 |
nicklas |
58 |
ItemSubtype subtype = itemList.getItemSubtype(); |
6771 |
16 Mar 15 |
nicklas |
59 |
RawDataType rawDataType = itemList.getRawDataType(); |
6927 |
04 Jun 15 |
nicklas |
60 |
|
6927 |
04 Jun 15 |
nicklas |
61 |
// Load depending lists |
6927 |
04 Jun 15 |
nicklas |
62 |
List<ItemList> depending = new ArrayList<ItemList>(); |
6927 |
04 Jun 15 |
nicklas |
63 |
|
6927 |
04 Jun 15 |
nicklas |
64 |
List<ItemList> toCheck = new ArrayList<ItemList>(itemList.getDependingLists().list(dc)); |
6927 |
04 Jun 15 |
nicklas |
65 |
Set<ItemList> checked = new HashSet<ItemList>(); |
6927 |
04 Jun 15 |
nicklas |
66 |
while (toCheck.size() > 0) |
6927 |
04 Jun 15 |
nicklas |
67 |
{ |
6927 |
04 Jun 15 |
nicklas |
68 |
ItemList i = toCheck.remove(0); |
6927 |
04 Jun 15 |
nicklas |
69 |
if (checked.contains(i)) continue; // Skip lists that have already been checked |
6927 |
04 Jun 15 |
nicklas |
70 |
|
6927 |
04 Jun 15 |
nicklas |
71 |
checked.add(i); |
6927 |
04 Jun 15 |
nicklas |
72 |
|
6927 |
04 Jun 15 |
nicklas |
73 |
if (!i.getDisableSyncFilters() && i.hasSyncFilters()) |
6927 |
04 Jun 15 |
nicklas |
74 |
{ |
6927 |
04 Jun 15 |
nicklas |
75 |
// We depend on this list and should also check recursively |
6927 |
04 Jun 15 |
nicklas |
76 |
depending.add(i); |
6927 |
04 Jun 15 |
nicklas |
77 |
toCheck.addAll(i.getDependingLists().list(dc)); |
6927 |
04 Jun 15 |
nicklas |
78 |
} |
6927 |
04 Jun 15 |
nicklas |
79 |
} |
6771 |
16 Mar 15 |
nicklas |
80 |
%> |
6771 |
16 Mar 15 |
nicklas |
81 |
<base:page type="popup" title="<%=title%>"> |
6771 |
16 Mar 15 |
nicklas |
82 |
<base:head scripts="~resync.js" /> |
6771 |
16 Mar 15 |
nicklas |
83 |
<base:body> |
6811 |
30 Mar 15 |
nicklas |
84 |
<h1><%=title%> <base:help helpid="itemlist.resync" /></h1> |
6771 |
16 Mar 15 |
nicklas |
85 |
<form action="index.jsp?ID=<%=ID%>" method="post" name="resync"> |
6771 |
16 Mar 15 |
nicklas |
86 |
<input type="hidden" name="cmd" value="ReSync"> |
6771 |
16 Mar 15 |
nicklas |
87 |
<input type="hidden" name="item_id" value="<%=itemId%>"> |
6771 |
16 Mar 15 |
nicklas |
88 |
|
6771 |
16 Mar 15 |
nicklas |
89 |
<div class="content bottomborder"> |
6771 |
16 Mar 15 |
nicklas |
90 |
<table class="fullform input100"> |
6771 |
16 Mar 15 |
nicklas |
91 |
<tr class="big"> |
6771 |
16 Mar 15 |
nicklas |
92 |
<th>Sync options</th> |
6771 |
16 Mar 15 |
nicklas |
93 |
<td> |
6771 |
16 Mar 15 |
nicklas |
94 |
<label><input type="radio" name="syncoption" |
6771 |
16 Mar 15 |
nicklas |
95 |
value="FULL" checked>Full</label> - add and remove members<br> |
6771 |
16 Mar 15 |
nicklas |
96 |
<label><input type="radio" name="syncoption" |
6811 |
30 Mar 15 |
nicklas |
97 |
value="ADD_ONLY">Add only</label> - add members matching the filters<br> |
6771 |
16 Mar 15 |
nicklas |
98 |
<label><input type="radio" name="syncoption" |
6811 |
30 Mar 15 |
nicklas |
99 |
value="REMOVE_ONLY">Remove only</label> - remove members not matching the filters<br> |
6771 |
16 Mar 15 |
nicklas |
100 |
</td> |
6771 |
16 Mar 15 |
nicklas |
101 |
</tr> |
6771 |
16 Mar 15 |
nicklas |
102 |
<% |
6771 |
16 Mar 15 |
nicklas |
103 |
if (subtype != null) |
6771 |
16 Mar 15 |
nicklas |
104 |
{ |
6771 |
16 Mar 15 |
nicklas |
105 |
%> |
6771 |
16 Mar 15 |
nicklas |
106 |
<tr> |
6771 |
16 Mar 15 |
nicklas |
107 |
<th>Subtype</th> |
6771 |
16 Mar 15 |
nicklas |
108 |
<td> |
6771 |
16 Mar 15 |
nicklas |
109 |
<label><input type="checkbox" name="subtype" checked value="<%=subtype.getId()%>" |
6771 |
16 Mar 15 |
nicklas |
110 |
>Filter on <i><%=HTML.encodeTags(subtype.getName())%></i></label> |
6771 |
16 Mar 15 |
nicklas |
111 |
</td> |
6771 |
16 Mar 15 |
nicklas |
112 |
</tr> |
6771 |
16 Mar 15 |
nicklas |
113 |
<% |
6771 |
16 Mar 15 |
nicklas |
114 |
} |
6771 |
16 Mar 15 |
nicklas |
115 |
if (rawDataType != null) |
6771 |
16 Mar 15 |
nicklas |
116 |
{ |
6771 |
16 Mar 15 |
nicklas |
117 |
%> |
6771 |
16 Mar 15 |
nicklas |
118 |
<tr> |
6771 |
16 Mar 15 |
nicklas |
119 |
<th>Raw data type</th> |
6927 |
04 Jun 15 |
nicklas |
120 |
<td style="padding-bottom: 0.5em; padding-top: 0.5em;"> |
6771 |
16 Mar 15 |
nicklas |
121 |
<label><input type="checkbox" name="rawdatatype" checked value="<%=rawDataType.getId()%>" |
6771 |
16 Mar 15 |
nicklas |
122 |
>Filter on <i><%=HTML.encodeTags(rawDataType.getName())%></i></label> |
6771 |
16 Mar 15 |
nicklas |
123 |
</td> |
6771 |
16 Mar 15 |
nicklas |
124 |
</tr> |
6771 |
16 Mar 15 |
nicklas |
125 |
<% |
6771 |
16 Mar 15 |
nicklas |
126 |
} |
6771 |
16 Mar 15 |
nicklas |
127 |
%> |
6771 |
16 Mar 15 |
nicklas |
128 |
<tr class="dynamic"> |
6927 |
04 Jun 15 |
nicklas |
129 |
<th>Depending lists</th> |
6927 |
04 Jun 15 |
nicklas |
130 |
<td> |
6927 |
04 Jun 15 |
nicklas |
131 |
<% |
6927 |
04 Jun 15 |
nicklas |
132 |
if (depending.size() > 0) |
6927 |
04 Jun 15 |
nicklas |
133 |
{ |
6927 |
04 Jun 15 |
nicklas |
134 |
for (ItemList d : depending) |
6927 |
04 Jun 15 |
nicklas |
135 |
{ |
6927 |
04 Jun 15 |
nicklas |
136 |
boolean canSync = d.hasPermission(Permission.WRITE); |
6927 |
04 Jun 15 |
nicklas |
137 |
boolean inSync = d.isInSync(dc); |
6927 |
04 Jun 15 |
nicklas |
138 |
%> |
6927 |
04 Jun 15 |
nicklas |
139 |
<label><input type="checkbox" name="depending" value="<%=d.getId() %>" |
6927 |
04 Jun 15 |
nicklas |
140 |
<%=canSync ? "" : "disabled" %> <%=!inSync && canSync ? "checked" : "" %> |
6927 |
04 Jun 15 |
nicklas |
141 |
><%=HTML.encodeTags(d.getName()) %></label> |
6927 |
04 Jun 15 |
nicklas |
142 |
<i>(<%=canSync ? (inSync ? "appears to be in sync" : "not in sync") : "no write permissions" %>)</i><br> |
6927 |
04 Jun 15 |
nicklas |
143 |
<% |
6927 |
04 Jun 15 |
nicklas |
144 |
} |
6927 |
04 Jun 15 |
nicklas |
145 |
%> |
6927 |
04 Jun 15 |
nicklas |
146 |
<div class="messagecontainer note"> |
6927 |
04 Jun 15 |
nicklas |
147 |
The item lists above are used by the filters in this list.<br> |
6927 |
04 Jun 15 |
nicklas |
148 |
Selected lists will be synchronized before this list is synchronized. |
6927 |
04 Jun 15 |
nicklas |
149 |
</div> |
6927 |
04 Jun 15 |
nicklas |
150 |
<% |
6927 |
04 Jun 15 |
nicklas |
151 |
} |
6927 |
04 Jun 15 |
nicklas |
152 |
else |
6927 |
04 Jun 15 |
nicklas |
153 |
{ |
6927 |
04 Jun 15 |
nicklas |
154 |
%> |
6927 |
04 Jun 15 |
nicklas |
155 |
<div class="messagecontainer note"> |
6927 |
04 Jun 15 |
nicklas |
156 |
This list doesn't depend on any other item lists. |
6927 |
04 Jun 15 |
nicklas |
157 |
</div> |
6927 |
04 Jun 15 |
nicklas |
158 |
<% |
6927 |
04 Jun 15 |
nicklas |
159 |
} |
6927 |
04 Jun 15 |
nicklas |
160 |
%> |
6927 |
04 Jun 15 |
nicklas |
161 |
</td> |
6771 |
16 Mar 15 |
nicklas |
162 |
</tr> |
6771 |
16 Mar 15 |
nicklas |
163 |
</table> |
6771 |
16 Mar 15 |
nicklas |
164 |
|
6771 |
16 Mar 15 |
nicklas |
165 |
</div> |
6771 |
16 Mar 15 |
nicklas |
166 |
</form> |
6771 |
16 Mar 15 |
nicklas |
167 |
|
6771 |
16 Mar 15 |
nicklas |
168 |
<base:buttongroup subclass="dialogbuttons"> |
6771 |
16 Mar 15 |
nicklas |
169 |
<base:button id="btnSave" title="Ok" /> |
6771 |
16 Mar 15 |
nicklas |
170 |
<base:button id="close" title="Cancel" /> |
6771 |
16 Mar 15 |
nicklas |
171 |
</base:buttongroup> |
6771 |
16 Mar 15 |
nicklas |
172 |
</base:body> |
6771 |
16 Mar 15 |
nicklas |
173 |
</base:page> |
6771 |
16 Mar 15 |
nicklas |
174 |
<% |
6771 |
16 Mar 15 |
nicklas |
175 |
} |
6771 |
16 Mar 15 |
nicklas |
176 |
finally |
6771 |
16 Mar 15 |
nicklas |
177 |
{ |
6771 |
16 Mar 15 |
nicklas |
178 |
if (dc != null) dc.close(); |
6771 |
16 Mar 15 |
nicklas |
179 |
} |
6771 |
16 Mar 15 |
nicklas |
180 |
%> |