diff --git a/pom.xml b/pom.xml index 18d7d801..ba680415 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,13 @@ 3.1.0 1.19 + + + + netbeans.maven2.repository + http://bits.netbeans.org/maven2/ + + @@ -55,6 +62,7 @@ 1.7 1.7 + true @@ -90,7 +98,7 @@ mysql mysql-connector-java - 5.1.35 + 5.1.40 @@ -224,15 +232,16 @@ + org.slf4j slf4j-api - 1.7.6 + 1.7.21 org.slf4j slf4j-log4j12 - 1.7.6 + 1.7.21 @@ -457,7 +466,7 @@ mysql mysql-connector-java - 5.1.6 + 5.1.40 @@ -472,8 +481,6 @@ 1.8.3 - - com.parallax.client @@ -486,8 +493,29 @@ Cloud-Compiler-java-client 1.0-SNAPSHOT - - + + + + junit + junit + 4.11 + test + + + + + + \ No newline at end of file diff --git a/src/main/config/default/log4j.xml b/src/main/config/default/log4j.xml index da0f2592..7edfdbe0 100644 --- a/src/main/config/default/log4j.xml +++ b/src/main/config/default/log4j.xml @@ -6,9 +6,12 @@ - - - - - + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/parallax/server/blocklyprop/converter/ProjectConverter.java b/src/main/java/com/parallax/server/blocklyprop/converter/ProjectConverter.java index ae2d9524..55ec6d4e 100644 --- a/src/main/java/com/parallax/server/blocklyprop/converter/ProjectConverter.java +++ b/src/main/java/com/parallax/server/blocklyprop/converter/ProjectConverter.java @@ -84,10 +84,8 @@ public JsonObject toJson(ProjectRecord project) { result.addProperty("modified", DateConversion.toDateTimeString(project.getModified().getTime())); boolean isYours = project.getIdUser().equals(BlocklyPropSecurityUtils.getCurrentUserId()); result.addProperty("yours", isYours); - if (!isYours) { - result.addProperty("user", userService.getUserScreenName(project.getIdUser())); - - } else { + result.addProperty("user", userService.getUserScreenName(project.getIdUser())); + if (isYours) { List projectSharingRecords = projectSharingService.getSharingInfo(project.getId()); if (projectSharingRecords != null && !projectSharingRecords.isEmpty()) { result.addProperty("share-key", projectSharingRecords.get(0).getSharekey()); @@ -126,9 +124,7 @@ public JsonObject toJson(Project project) { result.addProperty("modified", DateConversion.toDateTimeString(project.getModified().getTime())); boolean isYours = project.getIdUser().equals(BlocklyPropSecurityUtils.getCurrentUserId()); result.addProperty("yours", isYours); - if (!isYours) { - result.addProperty("user", userService.getUserScreenName(project.getIdUser())); - } + result.addProperty("user", userService.getUserScreenName(project.getIdUser())); if (project.getBasedOn() != null) { JsonObject basedOn = new JsonObject(); diff --git a/src/main/java/com/parallax/server/blocklyprop/db/dao/ProjectDao.java b/src/main/java/com/parallax/server/blocklyprop/db/dao/ProjectDao.java index 531ccc43..7e46d0b3 100644 --- a/src/main/java/com/parallax/server/blocklyprop/db/dao/ProjectDao.java +++ b/src/main/java/com/parallax/server/blocklyprop/db/dao/ProjectDao.java @@ -19,19 +19,59 @@ public interface ProjectDao { ProjectRecord getProject(Long idProject); - ProjectRecord createProject(String name, String description, String descriptionHtml, String code, ProjectType type, String board, boolean privateProject, boolean sharedProject); - - ProjectRecord createProject(String name, String description, String descriptionHtml, ProjectType type, String board, boolean privateProject, boolean sharedProject); - - ProjectRecord updateProject(Long idProject, String name, String description, String descriptionHtml, boolean privateProject, boolean sharedProject); - - ProjectRecord updateProject(Long idProject, String name, String description, String descriptionHtml, String code, boolean privateProject, boolean sharedProject); - - ProjectRecord saveCode(Long idProject, String code); - - List getUserProjects(Long idUser, TableSort sort, TableOrder order, Integer limit, Integer offset); - - List getSharedProjects(TableSort sort, TableOrder order, Integer limit, Integer offset, Long idUser); + ProjectRecord createProject( + String name, + String description, + String descriptionHtml, + String code, + ProjectType type, + String board, + boolean privateProject, + boolean sharedProject); + + ProjectRecord createProject( + String name, + String description, + String descriptionHtml, + ProjectType type, + String board, + boolean privateProject, + boolean sharedProject); + + ProjectRecord updateProject( + Long idProject, + String name, + String description, + String descriptionHtml, + boolean privateProject, + boolean sharedProject); + + ProjectRecord updateProject( + Long idProject, + String name, + String description, + String descriptionHtml, + String code, + boolean privateProject, + boolean sharedProject); + + ProjectRecord saveCode( + Long idProject, + String code); + + List getUserProjects( + Long idUser, + TableSort sort, + TableOrder order, + Integer limit, + Integer offset); + + List getSharedProjects( + TableSort sort, + TableOrder order, + Integer limit, + Integer offset, + Long idUser); int countUserProjects(Long idUser); @@ -41,8 +81,13 @@ public interface ProjectDao { boolean deleteProject(Long idProject); - ProjectRecord updateProjectCode(Long idProject, String code); + ProjectRecord updateProjectCode( + Long idProject, + String code); - ProjectRecord saveProjectCodeAs(Long idProject, String code, String newName); + ProjectRecord saveProjectCodeAs( + Long idProject, + String code, + String newName); } diff --git a/src/main/java/com/parallax/server/blocklyprop/db/dao/impl/ProjectDaoImpl.java b/src/main/java/com/parallax/server/blocklyprop/db/dao/impl/ProjectDaoImpl.java index 01793327..481f90e3 100644 --- a/src/main/java/com/parallax/server/blocklyprop/db/dao/impl/ProjectDaoImpl.java +++ b/src/main/java/com/parallax/server/blocklyprop/db/dao/impl/ProjectDaoImpl.java @@ -14,6 +14,7 @@ import com.parallax.server.blocklyprop.db.generated.Tables; import com.parallax.server.blocklyprop.db.generated.tables.records.ProjectRecord; import com.parallax.server.blocklyprop.security.BlocklyPropSecurityUtils; +import java.util.GregorianCalendar; import java.util.List; import org.apache.shiro.authz.UnauthorizedException; import org.jooq.Condition; @@ -34,9 +35,52 @@ public void setDSLContext(DSLContext dsl) { this.create = dsl; } + private ProjectRecord alterReadRecord(ProjectRecord record) { + + String newCode = record.getCode(); + if (record.getType() == ProjectType.SPIN) { + newCode = newCode.replaceAll("block type=\"controls_if\"", "block type=\"controls_boolean_if\""); + newCode = newCode.replaceAll("block type=\"logic_compare\"", "block type=\"logic_boolean_compare\""); + newCode = newCode.replaceAll("block type=\"logic_operation\"", "block type=\"logic_boolean_operation\""); + newCode = newCode.replaceAll("block type=\"logic_negate\"", "block type=\"logic_boolean_negate\""); + newCode = newCode.replaceAll("block type=\"math_number\"", "block type=\"spin_integer\""); + + } else if (record.getType() == ProjectType.PROPC){ + newCode = newCode.replaceAll("field name=\"OP\">ADD + MINUS - MULTIPLY * DIVIDE / MODULUS % AND && AND_NOT && !LT<GT>LTE<=GTE>=EQ==NEQ!=INCHES_inchesCM_cm 0; + return create.deleteFrom(Tables.PROJECT) + .where(Tables.PROJECT.ID.equal(idProject)) + .execute() > 0; } @Override public ProjectRecord updateProjectCode(Long idProject, String code) { - ProjectRecord record = create.selectFrom(Tables.PROJECT).where(Tables.PROJECT.ID.equal(idProject)).fetchOne(); + ProjectRecord record = create.selectFrom(Tables.PROJECT) + .where(Tables.PROJECT.ID.equal(idProject)) + .fetchOne(); + + GregorianCalendar cal = new GregorianCalendar(); + cal.setTime(new java.util.Date()); + if (record != null) { Long idUser = BlocklyPropSecurityUtils.getCurrentUserId(); if (record.getIdUser().equals(idUser)) { record.setCode(code); + record.setModified(cal); record.update(); return record; } else { if (record.getShared()) { ProjectRecord cloned = doProjectClone(record); cloned.setCode(code); + cloned.setModified(cal); cloned.update(); return cloned; } @@ -213,11 +296,20 @@ public ProjectRecord saveProjectCodeAs(Long idProject, String code, String newNa } Long idUser = BlocklyPropSecurityUtils.getCurrentUserId(); if (original.getIdUser().equals(idUser) || original.getShared()) { // TODO check if friends - ProjectRecord cloned = createProject(newName, original.getDescription(), original.getDescriptionHtml(), code, original.getType(), original.getBoard(), original.getPrivate(), original.getShared(), original.getId()); + ProjectRecord cloned = createProject( + newName, + original.getDescription(), + original.getDescriptionHtml(), + code, + original.getType(), + original.getBoard(), + original.getPrivate(), + original.getShared(), + original.getId()); return cloned; } return null; } -} +} \ No newline at end of file diff --git a/src/main/java/com/parallax/server/blocklyprop/servlets/PingServlet.java b/src/main/java/com/parallax/server/blocklyprop/servlets/PingServlet.java index 60fdc011..60e3f863 100644 --- a/src/main/java/com/parallax/server/blocklyprop/servlets/PingServlet.java +++ b/src/main/java/com/parallax/server/blocklyprop/servlets/PingServlet.java @@ -24,7 +24,7 @@ public class PingServlet extends HttpServlet { */ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - resp.getWriter().write("pong"); + resp.getWriter().write("pong"); } } diff --git a/src/main/java/com/parallax/server/blocklyprop/servlets/ProjectCreationServlet.java b/src/main/java/com/parallax/server/blocklyprop/servlets/ProjectCreationServlet.java index 7d6a4938..e39dc8da 100644 --- a/src/main/java/com/parallax/server/blocklyprop/servlets/ProjectCreationServlet.java +++ b/src/main/java/com/parallax/server/blocklyprop/servlets/ProjectCreationServlet.java @@ -35,7 +35,8 @@ public void setProjectService(ProjectService projectService) { * Update user */ @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + protected void doPost(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { resp.setContentType("text/json"); JsonObject result = new JsonObject(); @@ -49,23 +50,34 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws S boolean privateProject = "private".equalsIgnoreCase(sharing); boolean sharedProject = "shared".equalsIgnoreCase(sharing); + // ProjectType can be on of two values; 'SPIN' or 'PROPC' ProjectType projectType = null; + try { projectType = ProjectType.valueOf(projectTypeString); if (projectType == null) { + // The project type we received is unknown. result.addProperty("success", false); - result.addProperty("message", "Invalid projecttype"); + result.addProperty("message", "Unknown Project Type " + projectTypeString ); resp.getWriter().write(result.toString()); return; } } catch (IllegalArgumentException iae) { + // The project type was not supplied. result.addProperty("success", false); - result.addProperty("message", "Invalid projecttype"); + result.addProperty("message", "Invalid Project Type"); resp.getWriter().write(result.toString()); return; } - ProjectRecord project = projectService.createProject(projectName, projectDescription, projectDescriptionHtml, privateProject, sharedProject, projectType, boardType); + ProjectRecord project = projectService.createProject( + projectName, projectDescription, + projectDescriptionHtml, + privateProject, + sharedProject, + projectType, + boardType); + result.addProperty("success", true); result.addProperty("id", project.getId()); resp.getWriter().write(result.toString()); diff --git a/src/main/resources/com/parallax/server/blocklyprop/internationalization/translations.properties b/src/main/resources/com/parallax/server/blocklyprop/internationalization/translations.properties index e752a41e..9994e8c7 100644 --- a/src/main/resources/com/parallax/server/blocklyprop/internationalization/translations.properties +++ b/src/main/resources/com/parallax/server/blocklyprop/internationalization/translations.properties @@ -26,8 +26,11 @@ footer.licenselink = License footer.changelog = Change log footer.librarieslink = External libraries footer.clientdownloadlink = BlocklyProp-client -footer.appversion = v0.93 -footer.buildversion = 252 + +# Application version numbers. +application.major = 0 +application.minor = 94 +application.build = 304 html.content_missing = Content missing @@ -77,6 +80,8 @@ project.details_title = Project details project.name = Name project.user = User project.board = Board +project.created = Created On +project.modified = Last Modified project.description = Description project.share-link = Share project using link project.sharing = Sharing @@ -97,6 +102,8 @@ project.table.description = Description project.table.board = Board project.table.user = User project.changed = Project changes have been saved +project.created = Created +project.modified = Modified project.create.title = Your project project.create.basic = Basic info @@ -114,6 +121,7 @@ project.create.previouslink = Previous project.board.activity-board = Propeller Activity Board WX project.board.s3 = Scribbler Robot project.board.heb = Hackable Electronic Badge +project.board.flip = Propeller Flip project.board.other = Other confirm.request.title = Email confirm request @@ -190,11 +198,12 @@ login.forgotlink = Forgot your password? login.notconfirmedlink = Email not yet confirmed? editor.newproject.title = New project -editor.newproject.spin = S3 Robot +editor.newproject.spin = Scribbler Robot editor.newproject.c = Propeller C editor.projects.title = Projects editor.view.title = View editor.view.blocks = Blocks +editor.view.code = Code editor.view.c = Propeller C editor.view.spin = Spin editor.view.xml = XML @@ -206,11 +215,25 @@ editor.run.terminal = Serial terminal editor.run.configure = Configure client editor.project = Project editor.save = Save -editor.save-as = Save as +editor.save-as = Save project as editor.client.title = BlocklyPropClient -editor.client.checking = Checking for BlocklyPropClient -editor.client.available = BlocklyPropClient available -editor.client.not-available = BlocklyPropClient not available +editor.client.checking = Looking for BlocklyPropClient +editor.client.available = Select the correct port, then click or . +editor.client.available.short = Select the correct port, then click . +editor.client.not-available = BlocklyPropClient is not running +editor.download = Download blocks file +editor.upload = Upload blocks file +editor.upload.selectfile = Select File +editor.upload.valid = The selected file appears valid. +editor.upload.notvalid = The selected file is not valid. +editor.upload.boardtype.warning = Warning! You are about to upload a blocks file from a different board than you are currently using. If the blocks you are trying to upload are not available for your current board, uploading this blocks file into your project may break your project. If your project does break after uploading this file - do not save it! Click your browser's refresh button to reload your project. +editor.clear-workspace = Clear workspace +editor.button.close = Close +editor.button.cancel = Cancel +editor.button.replace = Replace +editor.button.append = Append +editor.title.terminal = Terminal +editor.title.result = Result editor.demo.dialog.title = You are not logged in editor.demo.dialog.continue = Continue demo @@ -237,7 +260,9 @@ category.communicate.serial-terminal = Terminal category.communicate.oled = OLED category.communicate.protocols = Protocols category.communicate.xbee = XBee +category.communicate.WS2812B = RGB LEDs category.sensor-input = Sensor +category.sensor-input.LSM9DS1 = LSM9DS1 IMU category.sensor-input.etape = ETape liquid level category.sensor-input.hmc5883l = HMC5883L category.sensor-input.2axis-joystick = 2-axis Joystick @@ -277,3 +302,20 @@ category.hackable-electronic-badge.accelerometer = Accelerometer category.hackable-electronic-badge.touchpad-control = Touchpad Control category.functions = Functions category.variables = Variables +category.s3-simple = Simple Scribbler +category.s3-simple.simple-control = Simple Control +category.s3-simple.simple-sensors = Simple Sensors +category.s3-simple.simple-actions = Simple Actions +category.s3-math = Math +category.sensor-input.s3-line = Line +category.sensor-input.s3-obstacle = Obstacle +category.sensor-input.s3-light = Light +category.sensor-input.s3-stall = Stall +category.sensor-input.s3-button = Button +category.sensor-input.s3-ping = Ping))) +category.sensor-input.s3-pins = Pins +category.s3-actions = Actions +category.s3-actions.motors = Motors +category.s3-actions.sound = Sound +category.s3-actions.leds = LEDs +category.s3-actions.reset = Reset diff --git a/src/main/webapp/WEB-INF/includes/pageparts/editor-menu.jsp b/src/main/webapp/WEB-INF/includes/pageparts/editor-menu.jsp index 48136ae3..96dff12b 100644 --- a/src/main/webapp/WEB-INF/includes/pageparts/editor-menu.jsp +++ b/src/main/webapp/WEB-INF/includes/pageparts/editor-menu.jsp @@ -7,97 +7,80 @@ <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@ include file="/WEB-INF/includes/include.jsp"%> - diff --git a/src/main/webapp/WEB-INF/includes/pageparts/footer.jsp b/src/main/webapp/WEB-INF/includes/pageparts/footer.jsp index 9fdc5b19..990a8367 100644 --- a/src/main/webapp/WEB-INF/includes/pageparts/footer.jsp +++ b/src/main/webapp/WEB-INF/includes/pageparts/footer.jsp @@ -22,7 +22,7 @@ diff --git a/src/main/webapp/WEB-INF/includes/pageparts/projectform.jsp b/src/main/webapp/WEB-INF/includes/pageparts/projectform.jsp index fe922080..1afa6f3e 100644 --- a/src/main/webapp/WEB-INF/includes/pageparts/projectform.jsp +++ b/src/main/webapp/WEB-INF/includes/pageparts/projectform.jsp @@ -30,8 +30,18 @@
- - + + +
+ + + + + + + + +
@@ -116,6 +126,7 @@ "activity-board": "", "s3": "", "heb": "", + "flip": "", "other": "" }; diff --git a/src/main/webapp/WEB-INF/includes/pageparts/projecttable.jsp b/src/main/webapp/WEB-INF/includes/pageparts/projecttable.jsp index 701348e6..5fe71f25 100644 --- a/src/main/webapp/WEB-INF/includes/pageparts/projecttable.jsp +++ b/src/main/webapp/WEB-INF/includes/pageparts/projecttable.jsp @@ -55,6 +55,7 @@ "activity-board": "", "s3": "", "heb": "", + "flip": "", "other": "" }; diff --git a/src/main/webapp/WEB-INF/servlet/project/project-link-c.jsp b/src/main/webapp/WEB-INF/servlet/project/project-link-c.jsp index f21eb877..6380b755 100644 --- a/src/main/webapp/WEB-INF/servlet/project/project-link-c.jsp +++ b/src/main/webapp/WEB-INF/servlet/project/project-link-c.jsp @@ -103,7 +103,7 @@
@@ -89,13 +113,13 @@ diff --git a/src/main/webapp/editor/blocklyspin.jsp b/src/main/webapp/editor/blocklyspin.jsp index 3efcc412..26b384f9 100644 --- a/src/main/webapp/editor/blocklyspin.jsp +++ b/src/main/webapp/editor/blocklyspin.jsp @@ -61,6 +61,30 @@ + +