super(oprop);
}
protected Any (Attribute... field) {
-// ----------------------------------
for (int i=0; i<field.length; i++) {
if (field[i] == null) continue; // Happen when newing an Any object without property
if (field[i].getFrom().equals(this)) getAttributes().add(field[i]);
// ==============================================================================================================================
public Attribute getAttribute (Class<? extends Attribute> type) {
-// ---------------------------------------------------------------
for (Iterator<Attribute> i=getAttributes().iterator(); i.hasNext(); ) {
Attribute field = i.next();
if (field.getClass().equals(type)) return field;
// ==============================================================================================================================
protected boolean removeAttribute (Attribute field) {
-// ---------------------------------------------------
for (Iterator<Attribute> i=getAttributes().iterator(); i.hasNext(); ) {
if (!i.next().equals(field)) continue;
i.remove();
- //RKV if (this.isSaved()) Database.getCurSession().update(this);
return true;
}
return false;
}
public boolean setAttribute (Attribute field) {
-// ------------------------------------------------
Class<?> type = field.getClass();
-//RKV Session session = Database.getCurSession();
if (!field.getFrom().equals(this)) return false;
for (Iterator<Attribute> i=getAttributes().iterator(); i.hasNext(); ) {
break;
}
getAttributes().add(field);
- //RKVif (this.isSaved()) {
- //RKV if (!field.isSaved()) session.save(field);
- //RKV session.update(this);
- //RKV} // Else, when saving this, Hibernate will propagate the operation
return true;
}
/**
}
// Initialization constructor
protected Entity (ObjectProperties prop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
-// ----------------------------------------
super(prop);
}
}
public List<Relation> getRelations (Class<? extends Relation> type) {
-// -------------------------------------------------------------------
List<Relation> result = new Vector<Relation>();
for (Iterator<Relation> i=relations.iterator(); i.hasNext();) {
// ==============================================================================================================================
protected Set<Relation> getAllRelations () {
-// ------------------------------------------
return relations;
}
protected Relation addRelation (Relation link) {
-// ----------------------------------------------
-// Session session = Database.getSession();
-// session.save(link);
relations.add(link);
-// session.update(this);
if (link.isBidirectional()) {
Entity to = (Entity)link.getTo(); // Bidirectional relation are necessarily between entities
link = link.getReverse();
-// session.save(link);
-// if (to.relations == null) to.relations = new HashSet<Relation>();
to.relations.add(link);
-// session.update(to);
}
return link;
}
protected void removeRelation (Class<? extends Relation> type, Persistent to) {
-// -----------------------------------------------------------------------------
for (Iterator<Relation> i=relations.iterator(); i.hasNext();) {
Relation link = i.next();
if (!link.getClass().equals(type)) continue;
if (!link.getTo().equals(to)) continue;
i.remove();
- //RKV if (this.isSaved()) Database.getCurSession().update(this);
return;
}
}
* @param nowner the document to which this relation is moved
* */
public void moveTo (Entity nowner) {
- //RKV Session session = Database.getCurSession();
Entity oldOwner = this.owner;
this.owner = nowner;
nowner.getAllRelations().add(this);
oldOwner.getAllRelations().remove(this);
-// myold.getAllRelations().remove(this); Harmful as it leads to remove this relation from the database (!?)
- //RKV session.update(this);
- //RKV session.update(nowner);
if (this.isBidirectional()) {
Relation link = this.getReverse();
link.setTo(nowner);
- //RKV session.update(link);
}
}
package org.splat.dal.bo.kernel;
/**
- *
+ * Text attribute persistent class.
* @author Daniel Brunier-Coulin
* @copyright OPEN CASCADE 2012
*/
-
-
public abstract class TextAttribute extends Attribute {
- //private Text mytext;
- private String mytext;
-
-// ==============================================================================================================================
-// Constructors
-// ==============================================================================================================================
+ /**
+ * Text value.
+ */
+ private String mytext;
-// Database fetch constructor.
+ /**
+ * Database fetch constructor.
+ */
public TextAttribute () {
}
-// Initialization constructor
+ /**
+ * Initialization constructor.
+ * @param from the owner of this attribute
+ * @param value the value of this attribute
+ */
protected TextAttribute (Any from, String value) {
-// ----------------------------------------------
super(from);
mytext = value;
}
-// ==============================================================================================================================
-// Public member functions
-// ==============================================================================================================================
-
+ /**
+ * Get value of this attribute.
+ * @return text value
+ */
public String getValue () {
-// -------------------------
return mytext;
}
-// ==============================================================================================================================
-// Protected services
-// ==============================================================================================================================
-
+ /**
+ * Set value of this attribute.
+ * @param value the text value to set
+ */
public void setValue (String value) {
-// --------------------------------------
mytext = value;
-//RKV if (this.isSaved()) Database.getCurSession().update(this);
}
}
\ No newline at end of file
ConvertsRelation attach = new ConvertsRelation(aDoc, export,
description);
- // RKV Session session = Database.getSession();
// RKV session.save(export);
// RKV session.save(attach);
state));
}
// query.append(order);
- // return (List<SimulationContext>) Database.getSession().createQuery(
- // query.toString()).list();
return getSimulationContextDAO().getFilteredList(aCondition, anOrder);
}
# Generated file header
file.header=Don't edit manually. See the source in @config.src.dir@.
-wapp.root=D:/users/rkv/SIMAN/SIMAN_SRC/Workspace/Siman/WebContent/
-
-
# Generated file header
file.header=Don't edit manually. See the source in @config.src.dir@.
-wapp.root=c:/work/SIMAN/SIMAN_SRC/Workspace/Siman/WebContent/
-
-
# Generated file header
file.header=================================
-
-wapp.root=D:/users/rkv/SIMAN/SIMAN_SRC/Workspace/Siman/WebContent/
schema.version = D-0.3
wapp.version = D-0.5
-wapp.root = @wapp.root@
wapp.login = conf/login.conf
wapp.configuration = conf/som.xml
wapp.customization = conf/my.xml
import com.opensymphony.xwork2.ActionSupport;
-import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;
import org.apache.log4j.Logger;
import org.splat.wapp.Menu;
+/**
+ * Base Siman action.
+ */
public class Action extends ActionSupport implements ServletRequestAware, SessionAware {
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = -895295026709526501L;
+ /**
+ * Action logger.
+ */
+ protected static final Logger logger = Logger.getLogger(Action.class);
+
+ /**
+ * Http servlet request.
+ */
+ private HttpServletRequest request;
+ /**
+ * Http session container.
+ */
private Map<String, Object> session;
+ /**
+ * Error code.
+ */
private String mercode;
+ /**
+ * Current open study facade object.
+ */
private OpenStudy _openStudy;
+ /**
+ * Current open knowledge facade object.
+ */
private OpenKnowledge _openKnowledge;
+
/**
* MenuBarSettings bean.
*/
* TitleBarSettings bean.
*/
private TitleBarSettings _titleBarSettings;
-
- private HttpServletRequest request;
-
- /**
- * Serial version ID.
- */
- private static final long serialVersionUID = -895295026709526501L;
/**
- * Action logger.
+ * Injected application settings bean.
*/
- protected static final Logger logger = Logger.getLogger(Action.class);
+ private ApplicationSettings _applicationSettings;
public class DocumentTypeComparator implements Comparator<DocumentType> {
-// -----------------------------------------------------------------------
public int compare(DocumentType t1, DocumentType t2)
{
ResourceBundle locale = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
}
}
public class ContextTypeComparator implements Comparator<SimulationContextType> {
-// --------------------------------------------------------------------------------
public int compare(SimulationContextType t1, SimulationContextType t2)
{
ResourceBundle locale = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
// ==============================================================================================================================
protected void closeKnowledge () {
-// --------------------------------
OpenObject open = (OpenObject)session.remove("knowledge.open");
if (open != null) {
if (session.get("study.open") == null) open.clearFacades(); // For eventually reopening the knowledge from a fresh context
}
}
protected void closeStudy () {
-// ----------------------------
OpenObject open = (OpenObject)session.remove("study.open");
if (open != null) {
if (session.get("knowledge.open") == null) open.clearFacades(); // For eventually reopening the study from a fresh context
}
}
protected void connect (LoginContext context, User user) {
-// --------------------------------------------------------
OpenStudy open = getOpenStudy();
if (open != null) {
open.changeUser(user);
session.put("login.context", context); // For executing the deconnection, when requested
}
protected void disconnect () {
-// ----------------------------
OpenStudy open = getOpenStudy();
if (open != null) {
open.changeUser(null);
session.remove("login.context");
}
protected User getConnectedUser () {
-// ----------------------------------
ApplicationRights rights = (ApplicationRights)session.get("user.rights");
return rights.getUser(); // May be null
}
protected Menu getMenu (String name) {
-// ------------------------------------
return (Menu)session.get("menu." + name);
}
public void setOpenKnowledge (OpenKnowledge kelm) {
return _openStudy; // May be null
}
protected OpenKnowledge open (KnowledgeElement kelm) {
-// ----------------------------------------------------
OpenKnowledge open = _openKnowledge.open(kelm);
closeKnowledge(); // Just in case
return open;
}
protected OpenStudy open (Study study) {
-// --------------------------------------
- OpenStudy open = _openStudy.open(getConnectedUser(), study); // The connected user may be null
+ OpenStudy open = _openStudy.open(getConnectedUser(), study); // The connected user may be null
closeStudy(); // Just in case
session.put("study.open", open);
}
public String getErrorCode () {
-// -----------------------------
return mercode;
}
public Map<String, Object> getSession () {
-// ----------------------------------------
return session;
}
public void setErrorCode (String code) {
-// --------------------------------------
this.mercode = code;
}
public void setSession (Map<String, Object> session) {
-// ----------------------------------------------------
this.session = session;
}
public void setTitleBarSettings(TitleBarSettings titleBarSettings) {
_titleBarSettings = titleBarSettings;
}
+ /**
+ * Get the applicationSettings.
+ * @return the applicationSettings
+ */
+ public ApplicationSettings getApplicationSettings() {
+ return _applicationSettings;
+ }
+ /**
+ * Set the applicationSettings.
+ * @param applicationSettings the applicationSettings to set
+ */
+ public void setApplicationSettings(ApplicationSettings applicationSettings) {
+ _applicationSettings = applicationSettings;
+ }
}
\ No newline at end of file
import java.util.Set;
import java.util.Vector;
+import javax.servlet.ServletContext;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Node;
import org.splat.wapp.PopupItem;
import org.splat.wapp.SimpleMenu;
import org.splat.wapp.ToolBar;
+import org.springframework.web.context.ServletContextAware;
-public class ApplicationSettings {
+public class ApplicationSettings implements ServletContextAware {
/**
* Application settings logger.
protected final static Logger logger = Logger
.getLogger(ApplicationSettings.class);
+ /**
+ * Injected servlet context to get path to resources.
+ */
+ private ServletContext _servletContext;
+
private String wappserver;
private String wappname;
private Properties wapprops; // General properties from the application properties files
}
public String getApplicationRootPath() {
- // ---------------------------------------
- return getApplicationProperty("wapp.root"); // The property is supposed including the Web application name
+ //RKV: return getApplicationProperty("wapp.root"); // The property is supposed including the Web application name
+ return _servletContext.getRealPath("/");
}
public String getApplicationURL() {
public void setDocumentTypeService(DocumentTypeService documentTypeService) {
_documentTypeService = documentTypeService;
}
+
+ /**
+ * {@inheritDoc}
+ * @see org.apache.struts2.util.ServletContextAware#setServletContext(javax.servlet.ServletContext)
+ */
+ @Override
+ public void setServletContext(ServletContext context) {
+ _servletContext = context;
+ }
+
}
\ No newline at end of file
public String doInitialize() {
// -----------------------------
ResourceBundle label = ResourceBundle.getBundle("labels",
- ApplicationSettings.getCurrentLocale());
+ getApplicationSettings().getCurrentLocale());
ResourceBundle custom = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale());
+ getApplicationSettings().getCurrentLocale());
SimpleDateFormat datstring = new SimpleDateFormat(
custom.getString("date.format")); // Locale date display format
Step step;
mystudy = getOpenStudy();
Step step = mystudy.getSelectedStep();
doctypes = getStepService().getValidDocumentTypes(step);
- deftype = ApplicationSettings.getDefaultDocumentType(step, filext);
+ deftype = getApplicationSettings().getDefaultDocumentType(step, filext);
defuses = new Vector<Document>();
state = ProgressState.inWORK;
date = tool.extractProperty("date");
if (date != null) {
ResourceBundle locale = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale());
+ getApplicationSettings().getCurrentLocale());
SimpleDateFormat check = new SimpleDateFormat(
locale.getString("date.format"));
try {
} else { // Importation of a previously created template-based document
if (date.length() > 0) {
ResourceBundle locale = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale());
+ getApplicationSettings().getCurrentLocale());
SimpleDateFormat get = new SimpleDateFormat(
locale.getString("date.format"));
dprop.setDate(get.parse(date));
}
// Creation of derived the document formats
// Document ndoc = addoc.value();
- // Converter send = ApplicationSettings.getConverter(ndoc.getType(), ndoc.getFormat());
+ // Converter send = getApplicationSettings().getConverter(ndoc.getType(), ndoc.getFormat());
//
// if (send != null) send.converts(addoc); // Asynchronous process
Study study = mystudy.getStudyObject();
Scenario[] scene = study.getScenarii();
Scenario base = scene[scene.length-1]; // Default base scenario
- ResourceBundle locale = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale());
+ ResourceBundle locale = ResourceBundle.getBundle("labels", getApplicationSettings().getCurrentLocale());
myscene = Arrays.asList(scene);
scindex = base.getIndex();
// set the default name of the new study
ResourceBundle locale = ResourceBundle.getBundle("labels",
- ApplicationSettings.getCurrentLocale());
+ getApplicationSettings().getCurrentLocale());
title = locale.getString("label.study") + " "
+ String.valueOf(number + 1);
try {
// Addition of a default scenario
ResourceBundle locale = ResourceBundle.getBundle("labels",
- ApplicationSettings.getCurrentLocale());
+ getApplicationSettings().getCurrentLocale());
Scenario.Properties oprop = new Scenario.Properties();
oprop.setTitle(locale.getString("label.scenario") + " 1");
public OpenKnowledge open (KnowledgeElement knelm) {
// ---------------------------------------------
ResourceBundle label = ResourceBundle.getBundle("labels",
- ApplicationSettings.getCurrentLocale());
+ getApplicationSettings().getCurrentLocale());
ResourceBundle custom = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale());
+ getApplicationSettings().getCurrentLocale());
SimpleDateFormat convert = new SimpleDateFormat(
custom.getString("date.format"));
StringBuffer value = new StringBuffer(knelm.getValue());
public String getType() {
// ------------------------
return ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale()).getString(
+ getApplicationSettings().getCurrentLocale()).getString(
"type.knowledge." + myknelm.getType().getName());
}
* Injected project settings service.
*/
private ProjectSettingsService _projectSettingsService;
+ /**
+ * Injected application settings bean.
+ */
+ private ApplicationSettings _applicationSettings;
/**
* Injected publication service.
*/
KnowledgeElementTypeService knowledgeElementTypeService) {
_knowledgeElementTypeService = knowledgeElementTypeService;
}
+
+ /**
+ * Get the applicationSettings.
+ * @return the applicationSettings
+ */
+ public ApplicationSettings getApplicationSettings() {
+ return _applicationSettings;
+ }
+
+ /**
+ * Set the applicationSettings.
+ * @param applicationSettings the applicationSettings to set
+ */
+ public void setApplicationSettings(ApplicationSettings applicationSettings) {
+ _applicationSettings = applicationSettings;
+ }
}
\ No newline at end of file
public OpenStudy open(User user, Study study) {
// -----------------------------------------
ResourceBundle custom = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale());
+ getApplicationSettings().getCurrentLocale());
SimpleDateFormat datstring = new SimpleDateFormat(custom
.getString("date.format"));
Revision.Format verstring = new Revision.Format(getProjectSettings()
}
if (getStudyService().isStaffedBy(mystudy, cuser) || getStudyService().hasActor(mystudy, cuser)) {
// ProgressState state = mystudy.getProgressState();
- // if (state == ProgressState.inCHECK) popup = ApplicationSettings.getPopupMenu("stapprovable");
- // else if (state == ProgressState.APPROVED) popup = ApplicationSettings.getPopupMenu("stapproved");
- /* else */popup = ApplicationSettings
+ // if (state == ProgressState.inCHECK) popup = getApplicationSettings().getPopupMenu("stapprovable");
+ // else if (state == ProgressState.APPROVED) popup = getApplicationSettings().getPopupMenu("stapproved");
+ /* else */popup = getApplicationSettings()
.getPopupMenu("steditable");
popup.setContext("study", new StudyRights(cuser, mystudy));
}
public ToolBar getModuleBar() {
// ------------------------------
- return ApplicationSettings.getMe().getModuleBar(getSelectedStep());
+ return getApplicationSettings().getModuleBar(getSelectedStep());
}
public String getReference() {
public String getType() {
// ------------------------
return ResourceBundle.getBundle("labels",
- ApplicationSettings.getCurrentLocale())
+ getApplicationSettings().getCurrentLocale())
.getString("label.study");
}
// Transfer to the document of all known properties
ResourceBundle locale = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale());
+ getApplicationSettings().getCurrentLocale());
SimpleDateFormat get = new SimpleDateFormat(locale
.getString("date.format"));
Writer tool = Toolbox.getWriter(credoc);
.replaceAll("''", "'"));
tool.save();
- return new URL(ApplicationSettings.getDownloadURL(author)
+ return new URL(getApplicationSettings().getDownloadURL(author)
+ filename);
} catch (Exception saverror) {
logger.error("Reason:", saverror);
public void selectDocument(String docurl) {
// ------------------------------------------
- String prefix = ApplicationSettings.getRepositoryURL();
+ String prefix = getApplicationSettings().getRepositoryURL();
if (docurl.startsWith(prefix))
try {
cuser = user;
popup = null;
if (getStudyService().isStaffedBy(mystudy, cuser)) {
- popup = ApplicationSettings.getPopupMenu("steditable");
+ popup = getApplicationSettings().getPopupMenu("steditable");
popup.setContext("study", new StudyRights(cuser, mystudy));
}
//ustep = getProjectElementService().getFirstStep(mystudy);
import java.util.Map;
+import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;
+import org.apache.struts2.util.ServletContextAware;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
ProjectSettingsService project = getProjectSettings();
ApplicationSettings wapp = getApplicationSettings().init(wappurl.toString(), this.getLocale());
String root = wapp.getApplicationRootPath();
+ logger.debug("Application root: " + root);
// Database configuration
project.configure(root + wapp.getApplicationProperty("wapp.configuration"));
public final void setEditDisabledProperty(String editDisabledProperty) {
_editDisabledProperty = editDisabledProperty;
}
-
-
}
\ No newline at end of file
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;
import java.util.Vector;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
import org.splat.kernel.InvalidPropertyException;
import org.splat.dal.bo.kernel.Relation;
import org.splat.dal.bo.kernel.User;
import org.splat.manox.Reader;
import org.splat.manox.Toolbox;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.ProgressState;
import org.splat.service.PublicationService;
import org.splat.dal.bo.som.UsedByRelation;
import org.splat.dal.bo.som.UsesRelation;
+/**
+ * Action for creating a new version of a document.
+ */
public class VersionDocumentAction extends UploadBaseNextAction {
- private String index = null; // Versioned document index
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = -5702264003232132168L;
+
+ /**
+ * Versioned document index.
+ */
+ private String index = null;
+ /**
+ * List of publications which use the selected document.
+ */
private List<Publication> usedby = null;
+ /**
+ * List of selected impacted documents ids.
+ */
private long[] docusedby = null;
- private String summary = null; // Summary of changes in the new version
- private String docver = ""; // Version number extracted from the imported file, if exist
- private String date = ""; // Date extracted from the imported file, if exist
+ /**
+ * Summary of changes in the new version.
+ */
+ private String summary = null;
+ /**
+ * Version number extracted from the imported file, if exist.
+ */
+ private String docver = "";
+ /**
+ * Date extracted from the imported file, if exist.
+ */
+ private String date = "";
+ /**
+ * Injected project settings service.
+ */
private ProjectSettingsService _projectSettingsService;
+ /**
+ * Injected publication service.
+ */
private PublicationService _publicationService;
+ /**
+ * Injected step service.
+ */
private StepService _stepService;
/**
* Injected repository service.
*/
private RepositoryService _repositoryService;
/**
- * Value of the menu property.
- * It can be: none, create, open, study, knowledge, sysadmin, help.
+ * Value of the menu property. It can be: none, create, open, study, knowledge, sysadmin, help.
*/
private String _menuProperty;
-
+
/**
- * Value of the title bar property.
- * It can be: study, knowledge.
+ * Value of the title bar property. It can be: study, knowledge.
*/
private String _titleProperty;
-
- /**
- * Property that indicates whether the current open study is editable or not.
- * On the screen it looks like pen on the status icon, pop-up menu also can be called.
- * It is necessary for correct building the title bar.
- */
- private String _editDisabledProperty = "false";
/**
- * Serial version ID.
+ * Property that indicates whether the current open study is editable or not. On the screen it looks like pen on the status icon, pop-up
+ * menu also can be called. It is necessary for correct building the title bar.
*/
- private static final long serialVersionUID = -5702264003232132168L;
+ private String _editDisabledProperty = "false";
// ==============================================================================================================================
// Action methods
// ==============================================================================================================================
+ /**
+ * Initialize the action form.
+ *
+ * @return SUCCESS if succeeded, ERROR if uploaded file is XML and we can't extract properties from it
+ */
public String doInitialize() {
- // -----------------------------
-
+
setMenuProperty("study");
setTitleProperty("study");
setEditDisabledProperty("true");
- initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty);
-
- Session connex = Database.getCurSession();
- Transaction transax = connex.beginTransaction();
+ initializationScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty);
+
User user = getConnectedUser();
File updir = getRepositoryService().getDownloadDirectory(user);
File upfile = new File(updir.getPath() + "/" + filename);
defuses = new Vector<Document>();
usedby = new Vector<Publication>();
- Reader tool = Toolbox.getReader(upfile);
- if (tool != null) {
- String fileref = tool.extractProperty("reference");
- String filever = tool.extractProperty("version");
- if (fileref != null && !doc.getReference().equals(fileref)) {
- setErrorCode("reference.mismatch");
- return ERROR;
- }
- if (filever != null)
- try {
- Revision.Format get = new Revision.Format(
- getProjectSettings().getRevisionPattern());
- Revision newver = get.parse(filever);
- Revision oldver = new Revision(doc.getVersion());
- if (!newver.isGraterThan(oldver))
- throw new InvalidPropertyException("version");
- if (newver.isMinor())
- state = ProgressState.inWORK;
- else
- state = ProgressState.inDRAFT;
- docver = newver.toString();
- } catch (Exception e) {
- setErrorCode("version.mismatch");
- return ERROR;
- }
- summary = tool.extractProperty("history");
- date = tool.extractProperty("date");
- if (date != null) {
- ResourceBundle locale = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale());
- SimpleDateFormat check = new SimpleDateFormat(
- locale.getString("date.format"));
- try {
- check.parse(date);
- } catch (ParseException e) {
- setErrorCode("format.date");
- return ERROR;
- }
- } else
- date = "";
+ if (!extractProperties(upfile, doc)) {
+ return ERROR;
}
setupDefaultUses(deftype);
// Add additional documents used by the current version
for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
usedby.add(i.next());
}
- transax.commit();
return SUCCESS;
}
+ /**
+ * Try to extract properties from the uploaded file if it is XML.
+ *
+ * @param upfile
+ * the file to parse
+ * @param doc
+ * the document to version
+ * @return true if succeeded or if the file is not XML, otherwise return false
+ */
+ private boolean extractProperties(File upfile, Document doc) {
+ boolean res = true;
+ Reader tool = Toolbox.getReader(upfile);
+ if (tool != null) {
+ String fileref = tool.extractProperty("reference");
+ String filever = tool.extractProperty("version");
+ if (fileref != null && !doc.getReference().equals(fileref)) {
+ setErrorCode("reference.mismatch");
+ res = false;
+ } else {
+ if (filever != null) {
+ try {
+ Revision.Format get = new Revision.Format(
+ getProjectSettings().getRevisionPattern());
+ Revision newver = get.parse(filever);
+ Revision oldver = new Revision(doc.getVersion());
+ if (!newver.isGraterThan(oldver)) {
+ throw new InvalidPropertyException("version");
+ }
+ if (newver.isMinor()) {
+ state = ProgressState.inWORK;
+ } else {
+ state = ProgressState.inDRAFT;
+ }
+ docver = newver.toString();
+ } catch (Exception e) {
+ setErrorCode("version.mismatch");
+ res = false;
+ }
+ }
+ if (res) {
+ summary = tool.extractProperty("history");
+ date = tool.extractProperty("date");
+ if (date != null) {
+ ResourceBundle locale = ResourceBundle.getBundle("som",
+ getApplicationSettings().getCurrentLocale());
+ SimpleDateFormat check = new SimpleDateFormat(locale
+ .getString("date.format"));
+ try {
+ check.parse(date);
+ } catch (ParseException e) {
+ setErrorCode("format.date");
+ res = false;
+ }
+ } else {
+ date = "";
+ }
+ }
+ }
+ }
+ return res;
+ }
+
+ /**
+ * Create a new version of the selected document.
+ *
+ * @return SUCCESS - if succeeded, "cancel" - if canceled, ERROR - if failed
+ */
public String doVersion() {
- // -------------------------
setMenuProperty("study");
setTitleProperty("study");
setEditDisabledProperty("true");
- initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty);
-
+ initializationScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty);
+
if (action == ToDo.cancel)
return "cancel";
mystudy = getOpenStudy();
User user = getConnectedUser();
Step step = mystudy.getSelectedStep();
-// List<Step> steps = mystudy.getInvolvedSteps();
Date aDate = null;
if (date.length() > 0) {
ResourceBundle locale = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale());
- SimpleDateFormat get = new SimpleDateFormat(
- locale.getString("date.format"));
+ getApplicationSettings().getCurrentLocale());
+ SimpleDateFormat get = new SimpleDateFormat(locale
+ .getString("date.format"));
aDate = get.parse(date);
}
-
+
String[] listDocuses = null;
if (docuses != null) {
listDocuses = docuses.split(",");
}
- getPublicationService().versionDocument(step, user, filename, Integer.valueOf(index), docver,
- summary, state, aDate, listDocuses, docusedby/*, steps*/);
- /* File updir = getRepositoryService().getDownloadDirectory(user);
- File upfile = new File(updir.getPath() + "/" + filename);
-
- // Versioning of the document
- Document.Properties dprop = new Document.Properties();
- Publication current = step.getDocument(Integer.valueOf(index));
- Publication next;
-
- if (docver.length() == 0) { // Importation of a foreign document
- next = getStepService().versionDocument(step, current, dprop.setAuthor(user)
- .setDescription(summary));
- updir = next.getSourceFile().asFile();
- if (logger.isInfoEnabled())
- logger.info("Moving \"" + upfile.getName() + "\" to \""
- + updir.getPath() + "\".");
- upfile.renameTo(updir);
- try {
- getPublicationService().saveAs(next, state); // May throw FileNotFound if rename was not done
- } catch (FileNotFoundException saverror) {
- Thread.sleep(1000);
- logger.info("Waiting for the file.");
- upfile.renameTo(updir);
- getPublicationService().saveAs(next, state); // Forget it if throw again FileNotFound
- }
- } else {
- if (date.length() > 0) {
- ResourceBundle locale = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale());
- SimpleDateFormat get = new SimpleDateFormat(
- locale.getString("date.format"));
- dprop.setDate(get.parse(date));
- }
- next = getStepService().versionDocument(step, current, dprop.setAuthor(user)
- .setDescription(summary));
- updir = next.getSourceFile().asFile();
- if (logger.isInfoEnabled())
- logger.info("Moving \"" + upfile.getName() + "\" to \""
- + updir.getPath() + "\".");
- upfile.renameTo(updir);
- try {
- getPublicationService().saveAs(next, new Revision(docver));
- } catch (FileNotFoundException saverror) {
- Thread.sleep(1000);
- logger.info("Waiting for the file.");
- upfile.renameTo(updir);
- getPublicationService().saveAs(next, state);
- }
- }
- // TODO: Remove current document details from the contents of open study
+ getPublicationService().versionDocument(step, user, filename,
+ Integer.valueOf(index), docver, summary, state, aDate,
+ listDocuses, docusedby);
- // Creation of uses relations
- if (docuses != null) {
- String[] list = docuses.split(",");
- for (int i = 0; i < list.length; i++) {
- Integer index = Integer.valueOf(list[i].trim());
- Publication used = getPublication(index);
- next.addDependency(used);
- }
- }
- // Outdating impacted document
- HashSet<Integer> compatible = new HashSet<Integer>();
- if (docusedby != null) {
- String[] list = docusedby.split(",");
- for (int i = 0; i < list.length; i++)
- compatible.add(Integer.valueOf(list[i].trim()));
- }
- List<Publication> relist = current
- .getRelations(UsedByRelation.class);
- for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
- Publication using = i.next();
- if (!compatible.contains(using.getIndex()))
- getPublicationService().outdate(using);
- }
-*/
// Update of the open study
mystudy.setSelection(mystudy.getSelection()); // Rebuilds the presentation
// TODO: Look is an optimization is possible (for example by updating the presentation of versioned document)
// ==============================================================================================================================
public String getDate() {
- // ------------------------
return date;
}
public List<Publication> getDependencies() {
- // -------------------------------------------
return usedby;
}
public String getDescription() {
- // -------------------------------
return summary;
}
public String getIndex() {
- // -------------------------
return index;
}
public String getVersion() {
- // ---------------------------
return docver;
}
public void setDate(String date) {
- // ---------------------------------
this.date = date;
}
public void setDefaultDescription(String summary) {
- // --------------------------------------------------
if (this.summary == null)
this.summary = summary;
}
public void setDescription(String summary) {
- // -------------------------------------------
this.summary = summary;
}
public void setIndex(String index) {
- // -----------------------------------
this.index = index;
}
public void setUsedBy(long[] list) {
- // -----------------------------------
this.docusedby = list;
}
public void setVersion(String value) {
- // -------------------------------------
this.docver = value;
}
/**
* Get the stepService.
+ *
* @return the stepService
*/
public StepService getStepService() {
/**
* Set the stepService.
- * @param stepService the stepService to set
+ *
+ * @param stepService
+ * the stepService to set
*/
public void setStepService(StepService stepService) {
_stepService = stepService;
/**
* Get the repositoryService.
+ *
* @return the repositoryService
*/
public RepositoryService getRepositoryService() {
/**
* Set the repositoryService.
- * @param repositoryService the repositoryService to set
+ *
+ * @param repositoryService
+ * the repositoryService to set
*/
public void setRepositoryService(RepositoryService repositoryService) {
_repositoryService = repositoryService;
}
-
+
/**
* Get the menuProperty.
+ *
* @return the menuProperty
*/
public String getMenuProperty() {
/**
* Set the menuProperty.
- * @param menuProperty the menuProperty to set
+ *
+ * @param menuProperty
+ * the menuProperty to set
*/
public void setMenuProperty(String menuProperty) {
this._menuProperty = menuProperty;
}
-
+
/**
* Get the _titleProperty.
+ *
* @return the _titleProperty
*/
public String getTitleProperty() {
/**
* Set the _titleProperty.
- * @param _titleProperty the titleProperty to set
+ *
+ * @param titleProperty
+ * the titleProperty to set
*/
public void setTitleProperty(String titleProperty) {
_titleProperty = titleProperty;
/**
* Get the _editDisabledProperty.
+ *
* @return the _editDisabledProperty
*/
public String getEditDisabledProperty() {
/**
* Set the _editDisabledProperty.
- * @param _editDisabledProperty the _editDisabledProperty to set
+ *
+ * @param _editDisabledProperty
+ * the _editDisabledProperty to set
*/
public void setEditDisabledProperty(String _editDisabledProperty) {
this._editDisabledProperty = _editDisabledProperty;
<property name="projectSettings" ref="projectSettings" />
<property name="documentTypeService" ref="documentTypeService" />
</bean>
-
- <bean id="menuBarSettings"
- class="org.splat.simer.MenuBarSettings" scope="session">
+
+ <bean id="menuBarSettings" class="org.splat.simer.MenuBarSettings"
+ scope="session">
</bean>
-
- <bean id="titleBarSettings"
- class="org.splat.simer.TitleBarSettings" scope="session">
+
+ <bean id="titleBarSettings" class="org.splat.simer.TitleBarSettings"
+ scope="session">
</bean>
<bean id="slidMenu" scope="session" abstract="true">
<bean id="openObject" abstract="true"
class="org.splat.simer.OpenObject" scope="session">
+ <property name="applicationSettings" ref="applicationSettings" />
<property name="projectElementService"
ref="projectElementService" />
<property name="projectSettings" ref="projectSettings" />
<bean id="baseAction" class="org.splat.simer.Action"
scope="prototype" abstract="true">
+ <property name="applicationSettings" ref="applicationSettings" />
<property name="openStudy" ref="openStudy" />
<property name="openKnowledge" ref="openKnowledge" />
<property name="menuBarSettings" ref="menuBarSettings" />
<property name="projectSettings" ref="projectSettings" />
<property name="publicationService" ref="publicationService" />
<property name="repositoryService" ref="repositoryService" />
- <property name="documentService" ref="documentService" />
- <property name="documentTypeService" ref="documentTypeService" />
+ <property name="documentService" ref="documentService" />
+ <property name="documentTypeService" ref="documentTypeService" />
</bean>
<bean id="displayStudyStepAction"
class="org.splat.simer.EditSimulationContextAction" scope="prototype"
parent="displayStudyStepAction">
<property name="stepService" ref="stepService" />
- <property name="simulationContextService"
- ref="simulationContextService" />
- <property name="simulationContextTypeService"
- ref="simulationContextTypeService" />
+ <property name="simulationContextService"
+ ref="simulationContextService" />
+ <property name="simulationContextTypeService"
+ ref="simulationContextTypeService" />
</bean>
<bean id="editDocumentAction"
<!-- End of Inherited from displayStudyStepAction -->
<bean id="startAction" class="org.splat.simer.StartAction"
- scope="prototype" parent ="baseAction">
+ scope="prototype" parent="baseAction">
<property name="applicationSettings" ref="applicationSettings" />
<property name="projectSettings" ref="projectSettings" />
</bean>
<bean id="connectionAction" class="org.splat.simer.ConnectionAction"
- scope="prototype" parent ="baseAction">
+ scope="prototype" parent="baseAction">
</bean>
<bean id="menuAction" class="org.splat.simer.MenuAction"
</bean>
<bean id="notYetImplementedAction"
- class="org.splat.simer.NotYetImplementedAction"
- scope="prototype" parent ="baseAction">
+ class="org.splat.simer.NotYetImplementedAction" scope="prototype"
+ parent="baseAction">
</bean>
<bean id="searchStudyAction"
- class="org.splat.simer.SearchStudyAction"
- scope="prototype" parent ="baseAction">
+ class="org.splat.simer.SearchStudyAction" scope="prototype"
+ parent="baseAction">
<property name="projectSettings" ref="projectSettings" />
<property name="searchService" ref="searchService" />
<property name="simulationContextService"
</bean>
<bean id="searchKnowledgeAction"
- class="org.splat.simer.SearchKnowledgeAction"
- scope="prototype" parent ="baseAction">
+ class="org.splat.simer.SearchKnowledgeAction" scope="prototype"
+ parent="baseAction">
<property name="searchService" ref="searchService" />
<property name="simulationContextService"
ref="simulationContextService" />
</bean>
<bean id="displayKnowledgeAction"
- class="org.splat.simer.DisplayKnowledgeAction"
- scope="prototype" parent ="baseAction">
+ class="org.splat.simer.DisplayKnowledgeAction" scope="prototype"
+ parent="baseAction">
<property name="knowledgeElementService"
ref="knowledgeElementService" />
</bean>
<bean id="uploadAction" class="org.splat.simer.UploadAction"
- scope="prototype" parent ="baseAction">
+ scope="prototype" parent="baseAction">
<property name="repositoryService" ref="repositoryService" />
</bean>
-
- <bean id="uploadStudyAction" class="org.splat.simer.UploadStudyAction"
- scope="prototype" parent ="baseAction">
+
+ <bean id="uploadStudyAction"
+ class="org.splat.simer.UploadStudyAction" scope="prototype"
+ parent="baseAction">
</bean>
<bean id="versionDocumentAction"
- class="org.splat.simer.VersionDocumentAction"
- scope="prototype" parent ="baseAction">
+ class="org.splat.simer.VersionDocumentAction" scope="prototype"
+ parent="baseAction">
<property name="projectSettings" ref="projectSettings" />
<property name="publicationService" ref="publicationService" />
<property name="stepService" ref="stepService" />
</bean>
<bean id="databaseIndexingAction"
- class="org.splat.simer.admin.DatabaseIndexingAction"
- scope="prototype" parent ="baseAction">
+ class="org.splat.simer.admin.DatabaseIndexingAction" scope="prototype"
+ parent="baseAction">
<property name="searchService" ref="searchService" />
</bean>
<bean id="importUserAction"
- class="org.splat.simer.admin.ImportUserAction"
- scope="prototype" parent="baseAction">
+ class="org.splat.simer.admin.ImportUserAction" scope="prototype"
+ parent="baseAction">
<property name="repositoryService" ref="repositoryService" />
<property name="userService" ref="userService" />
</bean>