14 package cz.vutbr.fit.knot.annotations.web;
26 import java.io.Serializable;
27 import java.util.Iterator;
28 import java.util.List;
29 import javax.faces.bean.ManagedBean;
30 import javax.faces.bean.SessionScoped;
31 import javax.persistence.EntityManager;
32 import javax.persistence.EntityTransaction;
33 import javax.persistence.Query;
66 return AppBean.getServerUri();
103 String oldURI = AppBean.getServerUri();
104 AppBean.setServerUri(
newURI);
106 EntityManager em = AppBean.getPersistenceManager().getEM();
107 EntityTransaction transaction = em.getTransaction();
111 Query q = em.createNamedQuery(
"Annotation.findAll");
112 List aList = q.getResultList();
113 if (aList != null && !aList.isEmpty()) {
114 Iterator aIt = aList.iterator();
115 while (aIt.hasNext()) {
117 String src = a.getSource();
118 String aid = a.getAuthorIdStr();
119 if (src != null && src.startsWith(oldURI)) {
120 src =
newURI + src.substring(oldURI.length(), src.length());
123 if (aid != null && aid.startsWith(oldURI)) {
124 aid =
newURI + aid.substring(oldURI.length(), src.length());
125 a.setAuthorIdStr(aid);
131 q = em.createNamedQuery(
"AnnotType.findAll");
132 aList = q.getResultList();
133 if (aList != null && !aList.isEmpty()) {
134 Iterator aIt = aList.iterator();
135 while (aIt.hasNext()) {
137 String uri = a.getUri();
138 String oUri = a.getUriInOntology();
139 if (uri != null && uri.startsWith(oldURI)) {
140 uri =
newURI + uri.substring(oldURI.length(), uri.length());
143 if (oUri != null && oUri.startsWith(oldURI)) {
144 oUri =
newURI + oUri.substring(oldURI.length(), oUri.length());
145 a.setUriInOntology(oUri);
151 q = em.createNamedQuery(
"AnnotTypeAttr.findAll");
152 aList = q.getResultList();
153 if (aList != null && !aList.isEmpty()) {
154 Iterator aIt = aList.iterator();
155 while (aIt.hasNext()) {
157 String oUri = a.getUriInOntology();
158 if (oUri != null && oUri.startsWith(oldURI)) {
159 oUri =
newURI + oUri.substring(oldURI.length(), oUri.length());
160 a.setUriInOntology(oUri);
166 q = em.createNamedQuery(
"StoredDocument.findAll");
167 aList = q.getResultList();
168 if (aList != null && !aList.isEmpty()) {
169 Iterator aIt = aList.iterator();
170 while (aIt.hasNext()) {
172 String oUri = d.getUri();
173 if (oUri != null && oUri.startsWith(oldURI)) {
174 oUri =
newURI + oUri.substring(oldURI.length(), oUri.length());
181 q = em.createNamedQuery(
"StoredDocument.findAll");
182 aList = q.getResultList();
183 if (aList != null && !aList.isEmpty()) {
184 Iterator aIt = aList.iterator();
185 while (aIt.hasNext()) {
187 String oUri = i.getSource();
188 if (oUri != null && oUri.startsWith(oldURI)) {
189 oUri =
newURI + oUri.substring(oldURI.length(), oUri.length());
196 q = em.createNamedQuery(
"Suggestion.findAll");
197 aList = q.getResultList();
198 if (aList != null && !aList.isEmpty()) {
199 Iterator aIt = aList.iterator();
200 while (aIt.hasNext()) {
202 String src = a.getSource();
203 String aid = a.getAuthorIdStr();
204 if (src != null && src.startsWith(oldURI)) {
205 src =
newURI + src.substring(oldURI.length(), src.length());
208 if (aid != null && aid.startsWith(oldURI)) {
209 aid =
newURI + aid.substring(oldURI.length(), src.length());
210 a.setAuthorIdStr(aid);
216 q = em.createNamedQuery(
"TypeAttrOnto.findAll");
217 aList = q.getResultList();
218 if (aList != null && !aList.isEmpty()) {
219 Iterator aIt = aList.iterator();
220 while (aIt.hasNext()) {
222 String oUri = a.getUriInOntology();
223 if (oUri != null && oUri.startsWith(oldURI)) {
224 oUri =
newURI + oUri.substring(oldURI.length(), oUri.length());
225 a.setUriInOntology(oUri);
231 q = em.createNamedQuery(
"ServerSetting.findByName");
233 aList = q.getResultList();
235 if (aList != null && !aList.isEmpty()) {
237 s.setSettingValue(
newURI);
244 transaction.commit();
245 }
catch (Exception e) {
246 transaction.rollback();
247 AppBean.setServerUri(oldURI);
248 errorMessage = errorMessage + MessageProvider.getMessage(
"dbError") +
" ";
254 return "serverSettingList";
265 }
else return "serverSettingList";
Backbean for administration of users.
static WebSession getSession()
Class representing attribute of unknown type of annotation.
Class representing parameter of server settings.
Class representing attribute of type of annotation.
Class for manipulating with session.
Singleton for storing global variables.
Class representing type of annotation.
Class representing item of subscripted or unsubscripted sources list.
static final String SERVER_URI_SETTING_NAME
Class representing stored document.
Class representing suggestion of annotation.
Class representing annotation.
void setNewUri(String newURI)