Skip to content

Commit

Permalink
issues OpenRoberta#114, OpenRoberta#180 - small save/saveas fix
Browse files Browse the repository at this point in the history
Artem Vinokurov committed Nov 4, 2019
1 parent b272f1a commit 6d50fe6
Showing 3 changed files with 32 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -35,8 +35,8 @@
import de.fhg.iais.roberta.util.ServerProperties;
import de.fhg.iais.roberta.util.Statistics;
import de.fhg.iais.roberta.util.Util;
import de.fhg.iais.roberta.util.UtilForREST;
import de.fhg.iais.roberta.util.UtilForHtmlXml;
import de.fhg.iais.roberta.util.UtilForREST;
import de.fhg.iais.roberta.util.dbc.DbcException;
import de.fhg.iais.roberta.util.jaxb.JaxbHelper;

@@ -80,7 +80,7 @@ public Response updateProject(@OraData HttpSessionState httpSessionState, JSONOb
String configText = dataPart.optString("configText", null);
boolean isShared = dataPart.optBoolean("shared", false);
Program program;
if ( dataPart.getString("cmd").equals("saveP") ) {
if ( dataPart.getString("cmd").equals("save") ) {
program =
programProcessor.persistProgramText(programName, programText, configName, configText, userId, robot, userId, programTimestamp, !isShared);
} else {
@@ -125,10 +125,10 @@ public Response getProgram(@OraData HttpSessionState httpSessionState, JSONObjec
} else {
String programName = dataPart.getString("programName");
String ownerName = dataPart.getString("owner");
String authorName = dataPart.getString("authorName");
String author = dataPart.getString("author");
String robot = getRobot(httpSessionState);

Program program = programProcessor.getProgram(programName, ownerName, robot, authorName);
Program program = programProcessor.getProgram(programName, ownerName, robot, author);
if ( program != null ) {
response.put("programText", program.getProgramText());
String configText = programProcessor.getProgramsConfig(program);
@@ -246,12 +246,12 @@ public Response getProgramEntity(@OraData HttpSessionState httpSessionState, JSO
UtilForREST.addErrorInfo(response, Key.USER_ERROR_NOT_LOGGED_IN);
} else {
String robot = getRobot(httpSessionState);
String programName = dataPart.getString("name");
String programName = dataPart.getString("programName");
String ownerName = dataPart.getString("owner");
String authorName = dataPart.getString("author");
String author = dataPart.getString("author");
User owner = up.getUser(ownerName);
int ownerID = owner.getId();
int authorId = up.getUser(authorName).getId();
int authorId = up.getUser(author).getId();
JSONArray program = programProcessor.getProgramEntity(programName, ownerID, robot, authorId);
if ( program != null ) {
response.put("program", program);
@@ -429,7 +429,7 @@ public Response deleteProject(@OraData HttpSessionState httpSessionState, JSONOb
} else {
String programName;
String author;
programName = dataPart.getString("name");
programName = dataPart.getString("programName");
author = dataPart.getString("author");
programProcessor.deleteByName(programName, userId, robot, author);
UtilForREST.addResultInfo(response, programProcessor);
@@ -470,14 +470,14 @@ public Response likeProject(@OraData HttpSessionState httpSessionState, JSONObje
} else {
String programName;
String robotName;
String authorName;
String author;
boolean like;
programName = dataPart.getString("programName");
robotName = dataPart.getString("robotName");
authorName = dataPart.getString("authorName");
author = dataPart.getString("author");
like = dataPart.getBoolean("like");
if ( like ) {
lp.createLike(programName, robotName, authorName);
lp.createLike(programName, robotName, author);
if ( lp.succeeded() ) {
// nothing to do
//argument: deleted tracks whether a like was set or taken away
@@ -487,7 +487,7 @@ public Response likeProject(@OraData HttpSessionState httpSessionState, JSONObje
Statistics.info("GalleryLike", "success", false);
}
} else {
lp.deleteLike(programName, robotName, authorName);
lp.deleteLike(programName, robotName, author);
Statistics.info("GalleryLike", "success", true, "deleted", true);
}
UtilForREST.addResultInfo(response, lp);
@@ -659,7 +659,7 @@ public Response getProjectRelations(@OraData HttpSessionState httpSessionState,
LOG.error("Unauthorized");
UtilForREST.addErrorInfo(response, Key.USER_ERROR_NOT_LOGGED_IN);
} else {
String programName = dataPart.getString("name");
String programName = dataPart.getString("programName");
JSONArray relations = programProcessor.getProgramRelations(programName, userId, robot, userId);
response.put("relations", relations);
UtilForREST.addResultInfo(response, programProcessor);
Original file line number Diff line number Diff line change
@@ -395,8 +395,13 @@ define([ 'exports', 'comm', 'message', 'log', 'util', 'guiState.controller', 'ro
}

function reloadProgram(opt_result, opt_fromShowSource) {
if (opt_result.data) {
program = opt_result.data;
//TODO: Clean this up
if (opt_result) {
if (opt_result.data) {
program = opt_result.data;
} else {
program = GUISTATE_C.getProgramXML();
}
} else {
program = GUISTATE_C.getProgramXML();
}
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ define([ 'exports', 'comm' ], function(exports, COMM) {
*/
function saveAsProgramToServer(programName, xmlProgramText, configName, xmlConfigText, timestamp, successFn) {
COMM.json("/program/save", {
"cmd" : "saveAs",
"programName" : programName,
"programText" : xmlProgramText,
"configName" : configName,
@@ -46,6 +47,7 @@ define([ 'exports', 'comm' ], function(exports, COMM) {
*/
function saveProgramToServer(programName, xmlProgramText, configName, xmlConfigText, programShared, timestamp, successFn) {
COMM.json("/program/save", {
"cmd" : "save",
"programName" : programName,
"programText" : xmlProgramText,
"configName" : configName,
@@ -134,7 +136,7 @@ define([ 'exports', 'comm' ], function(exports, COMM) {
*/
function deleteProgramFromListing(programName, author, successFn) {
COMM.json("/program/delete", {
"name" : programName,
"programName" : programName,
"author" : author,
}, function(result) {
successFn(result, programName);
@@ -152,11 +154,11 @@ define([ 'exports', 'comm' ], function(exports, COMM) {
* {String} - name of the owner of the program
*
*/
function loadProgramFromListing(programName, ownerName, authorName, successFn) {
function loadProgramFromListing(programName, ownerName, author, successFn) {
COMM.json("/program/listing", {
"name" : programName,
"programName" : programName,
"owner" : ownerName,
"authorName" : authorName
"author" : author
}, successFn, "load program '" + programName + "' owned by '" + ownerName + "'");
}

@@ -171,11 +173,11 @@ define([ 'exports', 'comm' ], function(exports, COMM) {
* {String} - name of the owner of the program
*
*/
function loadProgramEntity(programName, authorName, ownerName, successFn) {
function loadProgramEntity(programName, author, ownerName, successFn) {
COMM.json("/program/entity", {
"name" : programName,
"programName" : programName,
"owner" : ownerName,
"author" : authorName
"author" : author
}, successFn, "load programEntity '" + programName + "' owned by '" + ownerName + "'");
}

@@ -329,7 +331,7 @@ define([ 'exports', 'comm' ], function(exports, COMM) {
function checkProgramCompatibility(programName, configName, xmlTextProgram, xmlTextConfig, successFn) {
COMM.json("/program", {
"cmd" : "checkP",
"name" : programName,
"programName" : programName,
"configuration" : configName,
"programText" : xmlTextProgram,
"configurationText" : xmlTextConfig
@@ -345,11 +347,11 @@ define([ 'exports', 'comm' ], function(exports, COMM) {
* {String} - name of the program from the gallery
*
*/
function likeProgram(like, programName, authorName, robotName, successFn) {
function likeProgram(like, programName, author, robotName, successFn) {
COMM.json("/program/like", {
"programName" : programName,
"robotName" : robotName,
"authorName" : authorName,
"author" : author,
"like" : like
}, successFn, "like program '" + programName + "': '" + like + "'");
}

0 comments on commit 6d50fe6

Please sign in to comment.