import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
+import java.util.Map;
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.KnowledgeElementType;
import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.Publication;
+import org.splat.dal.bo.som.Scenario;
import org.splat.service.KnowledgeElementTypeService;
import org.splat.service.ProjectElementService;
import org.splat.service.PublicationService;
+import org.splat.service.dto.KnowledgeElementDTO;
import org.splat.service.dto.Proxy;
import org.splat.service.technical.ProjectSettingsService;
-import org.splat.dal.bo.som.Publication;
-import org.splat.dal.bo.som.Scenario;
import org.splat.som.Step;
+import org.splat.util.BeanHelper;
import org.splat.wapp.Menu;
import org.splat.wapp.PopupMenu;
public abstract class OpenObject implements Proxy {
- protected static HashMap<Long, DocumentFacade> docpres = null;
- protected static HashMap<Long, KnowledgeElementFacade> knowpres = null;
+ protected static Map<Long, DocumentFacade> docpres = null;
+ protected static Map<Long, KnowledgeElementFacade> knowpres = null;
/**
* Connected user.
protected KnowledgeElementType type;
protected List<KnowledgeElementFacade> list;
- public KnowledgeIterator(KnowledgeElementType type,
- List<KnowledgeElementFacade> list) {
+ public KnowledgeIterator(final KnowledgeElementType type,
+ final List<KnowledgeElementFacade> list) {
this.type = type;
this.list = list;
}
protected OpenObject() {
// -----------------------
// All member fields are supposed initialized by subclasses
- if (docpres == null)
+ if (docpres == null) {
docpres = new HashMap<Long, DocumentFacade>();
- if (knowpres == null)
+ }
+ if (knowpres == null) {
knowpres = new HashMap<Long, KnowledgeElementFacade>();
+ }
}
// ==============================================================================================================================
// Public member functions
// ==============================================================================================================================
- public void developDocument(String index) {
+ public void developDocument(final String index) {
// ------------------------------------------
for (Iterator<DocumentFacade> i = contents.iterator(); i.hasNext();) {
DocumentFacade doc = i.next();
- if (!doc.getIndex().equals(index))
+ if (!doc.getIndex().equals(index)) {
continue;
+ }
doc.develop();
return;
}
}
- public void developKnowledge(String index) {
+ public void developKnowledge(final String index) {
// -------------------------------------------
for (Iterator<KnowledgeIterator> i = knowledge.iterator(); i.hasNext();) {
List<KnowledgeElementFacade> knowelms = i.next()
for (Iterator<KnowledgeElementFacade> j = knowelms.iterator(); j
.hasNext();) {
KnowledgeElementFacade kelm = j.next();
- if (!kelm.getIndex().equals(index))
+ if (!kelm.getIndex().equals(index)) {
continue;
+ }
kelm.develop();
return;
}
knowpres.clear(); // For eventually reopening the knowledge from a fresh context
}
- public List<Document> collectInvolvedDocuments(DocumentType type) {
+ public List<Document> collectInvolvedDocuments(final DocumentType type) {
// ------------------------------------------------------------------
- List<Document> found = new Vector<Document>();
+ List<Document> found = new ArrayList<Document>();
for (Iterator<Step> i = involving.iterator(); i.hasNext();) {
Step step = i.next();
List<Publication> exist = step.getAllDocuments();
for (Iterator<Publication> j = exist.iterator(); j.hasNext();) {
Document doc = j.next().value();
- if (doc.getType().equals(type))
+ if (doc.getType().equals(type)) {
found.add(doc);
+ }
}
}
return found;
return (popup != null); // The pop-up is supposed existed when the user is staffed on the study
}
- public void reduceDocument(String index) {
+ public void reduceDocument(final String index) {
// -----------------------------------------
for (Iterator<DocumentFacade> i = contents.iterator(); i.hasNext();) {
DocumentFacade doc = i.next();
- if (!doc.getIndex().equals(index))
+ if (!doc.getIndex().equals(index)) {
continue;
+ }
doc.reduceAll();
return;
}
}
- public void reduceHistory(String index) {
+ public void reduceHistory(final String index) {
// ----------------------------------------
for (Iterator<DocumentFacade> i = contents.iterator(); i.hasNext();) {
DocumentFacade doc = i.next();
- if (!doc.getIndex().equals(index))
+ if (!doc.getIndex().equals(index)) {
continue;
+ }
doc.reduce();
return;
}
}
- public void reduceKnowledge(String index) {
+ public void reduceKnowledge(final String index) {
// ------------------------------------------
for (Iterator<KnowledgeIterator> i = knowledge.iterator(); i.hasNext();) {
List<KnowledgeElementFacade> knowelms = i.next()
for (Iterator<KnowledgeElementFacade> j = knowelms.iterator(); j
.hasNext();) {
KnowledgeElementFacade kelm = j.next();
- if (!kelm.getIndex().equals(index))
+ if (!kelm.getIndex().equals(index)) {
continue;
+ }
kelm.reduce();
return;
}
List<KnowledgeElement> kelms = scene.getAllKnowledgeElements();
Iterator<KnowledgeElement> more = kelms.iterator();
KnowledgeElement current = null;
- if (more.hasNext())
+ if (more.hasNext()) {
current = more.next();
+ }
- knowledge = new Vector<KnowledgeIterator>(types.size());
+ knowledge = new ArrayList<KnowledgeIterator>(types.size());
for (Iterator<KnowledgeElementType> i = types.iterator(); i
.hasNext();) {
KnowledgeElementType type = i.next();
- List<KnowledgeElementFacade> display = new Vector<KnowledgeElementFacade>(
+ List<KnowledgeElementFacade> display = new ArrayList<KnowledgeElementFacade>(
kelms.size());
while (current != null && current.getType().equals(type)) {
KnowledgeElementFacade facade = knowpres.get(current
.getIndex());
if (facade == null) {
- facade = new KnowledgeElementFacade(current);
+ facade = new KnowledgeElementFacade(BeanHelper.copyBean(current, KnowledgeElementDTO.class));
knowpres.put(current.getIndex(), facade);
}
display.add(facade);
- if (more.hasNext())
+ if (more.hasNext()) {
current = more.next();
- else
+ } else {
current = null;
+ }
}
knowledge.add(new KnowledgeIterator(type, display));
}
if (ustep.mayContain(Document.class)) {
List<Publication> list = ustep.getAllDocuments();
- contents = new Vector<DocumentFacade>(list.size());
+ contents = new ArrayList<DocumentFacade>(list.size());
for (Iterator<Publication> i = list.iterator(); i.hasNext();) {
Publication present = i.next();
Long index = present.getIndex();
* @param projectSettingsService
* project settings service
*/
- public void setProjectSettings(ProjectSettingsService projectSettingsService) {
+ public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
_projectSettingsService = projectSettingsService;
}
* @param publicationService
* the publicationService to set
*/
- public void setPublicationService(PublicationService publicationService) {
+ public void setPublicationService(final PublicationService publicationService) {
_publicationService = publicationService;
}
* @param menu
* the menu to set
*/
- public void setMenu(Menu menu) {
+ public void setMenu(final Menu menu) {
this.menu = menu;
}
* the projectElementService to set
*/
public void setProjectElementService(
- ProjectElementService projectElementService) {
+ final ProjectElementService projectElementService) {
_projectElementService = projectElementService;
}
* @param knowledgeElementTypeService the knowledgeElementTypeService to set
*/
public void setKnowledgeElementTypeService(
- KnowledgeElementTypeService knowledgeElementTypeService) {
+ final KnowledgeElementTypeService knowledgeElementTypeService) {
_knowledgeElementTypeService = knowledgeElementTypeService;
}
* Set the applicationSettings.
* @param applicationSettings the applicationSettings to set
*/
- public void setApplicationSettings(ApplicationSettings applicationSettings) {
+ public void setApplicationSettings(final ApplicationSettings applicationSettings) {
_applicationSettings = applicationSettings;
}
}
\ No newline at end of file