Refine search
@SuppressWarnings("unchecked") @Override public String toJSONString() { JSONArray jsonArray = new JSONArray(); for(String kw : keywords) { JSONObject data = new JSONObject(); data.put("name", kw); data.put("value", kw); jsonArray.add(data); } return jsonArray.toJSONString(); }
@SuppressWarnings( "unchecked" ) private String buildJsonQueryResult( QueryResult queryResult ) throws KettleException { JSONArray list = new JSONArray(); for ( SObject sobject : queryResult.getRecords() ) { list.add( buildJSONSObject( sobject ) ); } StringWriter sw = new StringWriter(); try { list.writeJSONString( sw ); } catch ( IOException e ) { throw new KettleException( e ); } return sw.toString(); }
@SuppressWarnings( "unchecked" ) private void outPutRow( Object[] rowData ) throws KettleStepException { // We can now output an object data.jg = new JSONObject(); data.jg.put( data.realBlocName, data.ja ); String value = data.jg.toJSONString(); if ( data.outputValue && data.outputRowMeta != null ) { Object[] outputRowData = RowDataUtil.addValueData( rowData, data.inputRowMetaSize, value ); incrementLinesOutput(); putRow( data.outputRowMeta, outputRowData ); } if ( data.writeToFile && !data.ja.isEmpty() ) { // Open a file if ( !openNewFile() ) { throw new KettleStepException( BaseMessages.getString( PKG, "JsonOutput.Error.OpenNewFile", buildFilename() ) ); } // Write data to file try { data.writer.write( value ); } catch ( Exception e ) { throw new KettleStepException( BaseMessages.getString( PKG, "JsonOutput.Error.Writing" ), e ); } // Close file closeFile(); } // Data are safe data.rowsAreSafe = true; data.ja = new JSONArray(); }
/** {@inheritDoc} */ @Override JSONObject toJson() { JSONObject ret = super.toJson(); if (hasSingleAttribute()) { ret.put("attribute",attributes.get(0)); } else if (!hasAllAttributes()) { JSONArray attrs = new JSONArray(); attrs.addAll(attributes); ret.put("attribute",attrs); } if (path != null) { ret.put("path",path); } return ret; }
JSONObject execJSON = (JSONObject) testCaseJSONObj.get("exec"); JSONObject preJSON = (JSONObject) testCaseJSONObj.get("pre"); JSONObject postJSON = new JSONObject(); if (testCaseJSONObj.containsKey("post")) { postJSON = (JSONObject) testCaseJSONObj.get("post"); JSONArray callCreates = new JSONArray(); if (testCaseJSONObj.containsKey("callcreates")) callCreates = (JSONArray) testCaseJSONObj.get("callcreates"); Object logsJSON = new JSONArray(); if (testCaseJSONObj.containsKey("logs")) logsJSON = testCaseJSONObj.get("logs");
/** * Saves to the file. */ @SuppressWarnings("unchecked") protected void save() { JSONArray array = new JSONArray(); for (BaseEntry entry : entries) { JSONObject obj = new JSONObject(); for (Entry<String, String> mapEntry : entry.write().entrySet()) { obj.put(mapEntry.getKey(), mapEntry.getValue()); } array.add(obj); } try (Writer writer = new FileWriter(file)) { array.writeJSONString(writer); } catch (Exception ex) { GlowServer.logger.log(Level.SEVERE, "Error writing to: " + file, ex); } }
public AbstractBackupPath set(List<AbstractBackupPath> bps, String snapshotName) throws Exception { File metafile = createTmpMetaFile(); try (FileWriter fr = new FileWriter(metafile)) { JSONArray jsonObj = new JSONArray(); for (AbstractBackupPath filePath : bps) jsonObj.add(filePath.getRemotePath()); fr.write(jsonObj.toJSONString()); } AbstractBackupPath backupfile = decorateMetaJson(metafile, snapshotName); fs.uploadFile( Paths.get(backupfile.getBackupFile().getAbsolutePath()), Paths.get(backupfile.getRemotePath()), backupfile, 10, true); addToRemotePath(backupfile.getRemotePath()); return backupfile; }
private void createEmptyFile() { try { FileWriter fileWriter = new FileWriter(HISTORY_FILE); JSONObject root = new JSONObject(); root.put("messages", new JSONArray()); fileWriter.write(root.toJSONString()); fileWriter.flush(); fileWriter.close(); } catch (IOException e) { logger.error("Error during creating history file: ", e); } }
public UserBean() { views = new JSONArray(); properties = new JSONObject(); }
@SuppressWarnings( "unchecked" ) public String getDatabases() { JSONArray list = new JSONArray(); for ( int i = 0; i < repositoriesMeta.nrDatabases(); i++ ) { JSONObject databaseJSON = new JSONObject(); databaseJSON.put( "name", repositoriesMeta.getDatabase( i ).getName() ); list.add( databaseJSON ); } return list.toString(); }
@Override protected void downloadFileImpl(Path remotePath, Path localPath) throws BackupRestoreException { AbstractBackupPath path = pathProvider.get(); path.parseRemote(remotePath.toString()); if (path.getType() == AbstractBackupPath.BackupFileType.META) { // List all files and generate the file try (FileWriter fr = new FileWriter(localPath.toFile())) { JSONArray jsonObj = new JSONArray(); for (AbstractBackupPath filePath : flist) { if (filePath.type == AbstractBackupPath.BackupFileType.SNAP && filePath.time.equals(path.time)) { jsonObj.add(filePath.getRemotePath()); } } fr.write(jsonObj.toJSONString()); fr.flush(); } catch (IOException io) { throw new BackupRestoreException(io.getMessage(), io); } } downloadedFiles.add(remotePath.toString()); }
/** * Gets the plugin specific data. * This method is called using Reflection. * * @return The plugin specific data. */ public JSONObject getPluginData() { JSONObject data = new JSONObject(); String pluginName = plugin.getDescription().getName(); String pluginVersion = plugin.getDescription().getVersion(); data.put("pluginName", pluginName); // Append the name of the plugin data.put("pluginVersion", pluginVersion); // Append the version of the plugin JSONArray customCharts = new JSONArray(); data.put("customCharts", customCharts); return data; }
@SuppressWarnings( "unchecked" ) public String getPlugins() { List<PluginInterface> plugins = pluginRegistry.getPlugins( RepositoryPluginType.class ); JSONArray list = new JSONArray(); for ( PluginInterface pluginInterface : plugins ) { if ( !pluginInterface.getIds()[0].equals( "PentahoEnterpriseRepository" ) ) { JSONObject repoJSON = new JSONObject(); repoJSON.put( "id", pluginInterface.getIds()[ 0 ] ); repoJSON.put( "name", pluginInterface.getName() ); repoJSON.put( "description", pluginInterface.getDescription() ); list.add( repoJSON ); } } return list.toString(); }
/** * Gets the plugin specific data. * This method is called using Reflection. * * @return The plugin specific data. */ public JSONObject getPluginData() { JSONObject data = new JSONObject(); String pluginName = plugin.getDescription().getName(); String pluginVersion = plugin.getDescription().getVersion(); data.put("pluginName", pluginName); // Append the name of the plugin data.put("pluginVersion", pluginVersion); // Append the version of the plugin JSONArray customCharts = new JSONArray(); data.put("customCharts", customCharts); return data; }
JSONObject obj = new JSONObject(); obj.put("name", this.getName()); obj.put("price", this.getPrice()); obj.put("description", this.getDescription()); obj.put("highlight", this.getHighlight()); obj.put("store", this.getStore()); obj.put("id", this.getId()); if(categories!=null) { JSONArray categoriesArray = new JSONArray(); for(String category : categories) { categoriesArray.add(category); obj.put("categories", categoriesArray); JSONArray tagsArray = new JSONArray(); for(String tag : tags) { tagsArray.add(tag); obj.put("tags", tagsArray);