private void createNewPreferencesFileFromTemplate() throws IOException, URISyntaxException { jsonFile.createNewFile(); File templateFile = loadWorkspacePrefTemplateFile(); json = new JSONObject(FileUtil.readFileContentsToString(templateFile, "UTF-8")); FileUtil.writePrettyPrintedJSONObjectToFile(json, jsonFile); }
@Override public Command createCommand(HttpServletRequest request, Workspace workspace) { ServletContextParameterMap contextParameters = ContextParametersRegistry.getInstance().getContextParameters(workspace.getContextId()); File uploadedFile = FileUtil.downloadFileFromHTTPRequest(request, contextParameters.getParameterValue(ContextParameter.USER_UPLOADED_DIR)); if (request.getParameter("revisedWorksheet") == null) { return new ImportAvroFileCommand(getNewId(workspace), Command.NEW_MODEL, uploadedFile); } return new ImportAvroFileCommand(getNewId(workspace), request.getParameter("revisedWorksheet"), uploadedFile); }
public JSONObject getSavedModels(String contextId) throws IOException { File file = getModelsFile(contextId); JSONObject json = new JSONObject(FileUtil.readFileContentsToString(file, "UTF-8")); return json; }
private File loadWorkspacePrefTemplateFile() throws IOException { ServletContextParameterMap contextParameters = ContextParametersRegistry.getInstance().getContextParameters(contextId); File file = new File(contextParameters.getParameterValue(ContextParameter.USER_CONFIG_DIRECTORY) + "/workspace-pref.template"); if(!file.exists()) { JSONObject json = new JSONObject(defaultWorkspaceTemplate); file.createNewFile(); FileUtil.writePrettyPrintedJSONObjectToFile(json, file); } return file; }
@Override public Command createCommand(HttpServletRequest request, Workspace workspace) { ServletContextParameterMap contextParameters = ContextParametersRegistry.getInstance().getContextParameters(workspace.getContextId()); File uploadedFile = FileUtil.downloadFileFromHTTPRequest(request, contextParameters.getParameterValue(ContextParameter.USER_UPLOADED_DIR)); if (request.getParameter("revisedWorksheet") == null) { return new ImportJSONFileCommand(getNewId(workspace), Command.NEW_MODEL, uploadedFile); } return new ImportJSONFileCommand(getNewId(workspace), request.getParameter("revisedWorksheet"), uploadedFile); }
private void loadDefaultPreferences() throws IOException, URISyntaxException { jsonFile = loadWorkspacePrefTemplateFile(); String templateStr = FileUtil.readFileContentsToString(jsonFile, "UTF-8"); json = new JSONObject(templateStr); }
private File getModelsFile(String contextId) throws IOException { ServletContextParameterMap contextParameters = ContextParametersRegistry.getInstance().getContextParameters(contextId); File file = new File(contextParameters.getParameterValue(ContextParameter.USER_PREFERENCES_DIRECTORY) + "/" + modelFile); if(!file.exists()) { JSONObject json = new JSONObject("{\"models\":[]}"); file.createNewFile(); FileUtil.writePrettyPrintedJSONObjectToFile(json, file); } return file; }
@Override public Command createCommand(HttpServletRequest request, Workspace workspace) { ServletContextParameterMap contextParameters = ContextParametersRegistry.getInstance().getContextParameters(workspace.getContextId()); File uploadedFile = FileUtil.downloadFileFromHTTPRequest(request, contextParameters.getParameterValue(ContextParameter.USER_UPLOADED_DIR)); if (request.getParameter("revisedWorksheet") == null) { return new ImportXMLFileCommand(getNewId(workspace), Command.NEW_MODEL, uploadedFile); } return new ImportXMLFileCommand(getNewId(workspace), request.getParameter("revisedWorksheet"), uploadedFile); }
public void saveModelUrl(String url, String contextId) throws JSONException, IOException { File file = getModelsFile(contextId); JSONObject json = new JSONObject(FileUtil.readFileContentsToString(file, "UTF-8")); JSONArray models = ((JSONArray)json.get("models")); JSONArray newModels = new JSONArray(); int modelIndex = modelExists(models, url); for(int i = Math.max(0, models.length() - maxNumUrls); i < models.length(); i ++) { if(modelIndex != i) { newModels.put(models.get(i)); } } newModels.put(url); json.put("models", newModels); FileUtil.writePrettyPrintedJSONObjectToFile(json, file); }
public XMLImport(File xmlFile, String worksheetName, Workspace workspace, String encoding, int maxNumLines, JSONArray columnsJson) { super(worksheetName, workspace, encoding); try { String fileContents = FileUtil.readFileContentsToString(xmlFile, encoding); JSONObject jsonObj = XML.toJSONObject(fileContents); Object json = JSONUtil.createJson(jsonObj.toString()); jsonImport = new JsonImport(json,this.getFactory(), this.getWorksheet(), workspace, maxNumLines); } catch (JSONException ex) { logger.error("Error in populating the worksheet with XML", ex); } catch (IOException ex) { logger.error("Error in reading the XML file", ex); } }
protected void savePreferences() throws JSONException, IOException { ServletContextParameterMap contextParameters = ContextParametersRegistry.getInstance().getContextParameters(contextId); ModelingConfiguration modelingConfiguration = ModelingConfigurationRegistry.getInstance().getModelingConfiguration(contextParameters.getKarmaHome()); if(modelingConfiguration.getOntologyAlignment() || modelingConfiguration.getKnownModelsAlignment()) { FileUtil.writePrettyPrintedJSONObjectToFile(json, jsonFile); } } }
@Override public Command createCommand(HttpServletRequest request, Workspace workspace) { ServletContextParameterMap contextParameters = ContextParametersRegistry.getInstance().getContextParameters(workspace.getContextId()); File uploadedFile = FileUtil.downloadFileFromHTTPRequest(request, contextParameters.getParameterValue(ContextParameter.USER_UPLOADED_DIR)); if (request.getParameter("revisedWorksheet") == null) { return new ImportExcelFileCommand(getNewId(workspace), Command.NEW_MODEL, uploadedFile); } return new ImportExcelFileCommand(getNewId(workspace), request.getParameter("revisedWorksheet"), uploadedFile); }
@Override public Command createCommand(HttpServletRequest request, Workspace workspace) { ServletContextParameterMap contextParameters = ContextParametersRegistry.getInstance().getContextParameters(workspace.getContextId()); File uploadedFile = FileUtil.downloadFileFromHTTPRequest(request, contextParameters.getParameterValue(ContextParameter.USER_UPLOADED_DIR)); if(request.getParameter("revisedWorksheet") == null){ return new ImportJSONLinesFileCommand(getNewId(workspace), Command.NEW_MODEL, uploadedFile); } return new ImportJSONLinesFileCommand(getNewId(workspace), request.getParameter("revisedWorksheet"), uploadedFile); }
@Override public Command createCommand(HttpServletRequest request, Workspace workspace) { ServletContextParameterMap contextParameters = ContextParametersRegistry.getInstance().getContextParameters(workspace.getContextId()); File uploadedFile = FileUtil.downloadFileFromHTTPRequest(request, contextParameters.getParameterValue(ContextParameter.USER_UPLOADED_DIR)); if (request.getParameter("revisedWorksheet") == null) { return new ImportCSVFileCommand(getNewId(workspace), Command.NEW_MODEL, uploadedFile); } return new ImportCSVFileCommand(getNewId(workspace), request.getParameter("revisedWorksheet"), uploadedFile); }
@Override public Command createCommand(HttpServletRequest request, Workspace workspace) { String worksheetId = request.getParameter(Arguments.worksheetId.name()); ServletContextParameterMap contextParameters = ContextParametersRegistry.getInstance().getContextParameters(workspace.getContextId()); boolean override = Boolean.parseBoolean(request.getParameter(Arguments.override.name())); String url = request.getParameter(Arguments.url.name()); if(url == null) { File uploadedFile = FileUtil.downloadFileFromHTTPRequest(request, contextParameters.getParameterValue(ContextParameter.USER_UPLOADED_DIR)); return new ApplyHistoryFromR2RMLModelCommand(getNewId(workspace), Command.NEW_MODEL, uploadedFile, worksheetId, override); } else { return new ApplyHistoryFromR2RMLModelCommand(getNewId(workspace), Command.NEW_MODEL, url, worksheetId, override); } }
@Override public Command createCommand(HttpServletRequest request, Workspace workspace) { ServletContextParameterMap contextParameters = ContextParametersRegistry.getInstance().getContextParameters(workspace.getContextId()); File uploadedFile = FileUtil.downloadFileFromHTTPRequest(request, contextParameters.getParameterValue(ContextParameter.USER_UPLOADED_DIR)); return new ImportOntologyCommand(getNewId(workspace), Command.NEW_MODEL, uploadedFile); }