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(); }
public JSONArray storeRecentSearch( String recentSearch ) { JSONArray recentSearches = getRecentSearches(); try { if ( recentSearch == null || recentSearches.contains( recentSearch ) ) { return recentSearches; } recentSearches.add( recentSearch ); if ( recentSearches.size() > 5 ) { recentSearches.remove( 0 ); } PropsUI props = PropsUI.getInstance(); String jsonValue = props.getRecentSearches(); JSONParser jsonParser = new JSONParser(); JSONObject jsonObject = jsonValue != null ? (JSONObject) jsonParser.parse( jsonValue ) : new JSONObject(); jsonObject.put( getLogin(), recentSearches ); props.setRecentSearches( jsonObject.toJSONString() ); } catch ( Exception e ) { e.printStackTrace(); } return recentSearches; }
@SuppressWarnings("unchecked") private void addResult(JSONArray ja, SearchResult result) { JSONObject document = new JSONObject(); document.putAll(result.getFields()); document.put("docid", result.getDocId()); document.put("query_relevance_score", result.getScore()); for(Entry<Integer, Double> entry: result.getVariables().entrySet()) { document.put("variable_" + entry.getKey(), entry.getValue()); } for(Entry<String, String> entry: result.getCategories().entrySet()) { document.put("category_" + entry.getKey(), entry.getValue()); } ja.add(document); }
/** * 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); } }
JSONObject jo = new JSONObject(); jo.put( outputField.getElementName(), data.inputRowMeta.getBoolean( row, data.fieldIndexes[i] ) ); break; case ValueMetaInterface.TYPE_INTEGER: jo.put( outputField.getElementName(), data.inputRowMeta.getInteger( row, data.fieldIndexes[i] ) ); break; case ValueMetaInterface.TYPE_NUMBER: jo.put( outputField.getElementName(), data.inputRowMeta.getNumber( row, data.fieldIndexes[i] ) ); break; case ValueMetaInterface.TYPE_BIGNUMBER: break; data.ja.add( jo );
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; }
@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(); }
public void execute( Object[] row ) throws KettleException { JSONObject jo = new JSONObject(); jo.put( outputField.getElementName(), data.inputRowMeta.getBoolean( row, data.fieldIndexes[i] ) ); break; case ValueMetaInterface.TYPE_INTEGER: jo.put( outputField.getElementName(), data.inputRowMeta.getInteger( row, data.fieldIndexes[i] ) ); break; case ValueMetaInterface.TYPE_NUMBER: jo.put( outputField.getElementName(), data.inputRowMeta.getNumber( row, data.fieldIndexes[i] ) ); break; case ValueMetaInterface.TYPE_BIGNUMBER: data.ja.add( jo );
@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()); }
@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(); }
@SuppressWarnings({"unchecked", "rawtypes"}) private static void prepareGMTOffsetTimeZones() { for (String tzId : new String[]{"GMT-12:00", "GMT-11:00", "GMT-10:00", "GMT-09:00", "GMT-08:00", "GMT-07:00", "GMT-06:00", "GMT-05:00", "GMT-04:00", "GMT-03:00", "GMT-02:00", "GMT-01:00", "GMT+01:00", "GMT+02:00", "GMT+03:00", "GMT+04:00", "GMT+05:00", "GMT+06:00", "GMT+07:00", "GMT+08:00", "GMT+09:00", "GMT+10:00", "GMT+11:00", "GMT+12:00"}) { TimeZone tz = TimeZone.getTimeZone(tzId); JSONObject json = new JSONObject(); json.put(JsonTags.TIME_ZOME_DISPLAY_NAME, tz.getDisplayName(false, TimeZone.SHORT) + " (" + tzId + ")"); json.put(JsonTags.TIME_ZONE_ID, tzId); GMTOffsetTimeZones.add(json); } }
/** * add the news stream according to the Activitystrea.ms format * * @param activities * news stream items */ @SuppressWarnings("unchecked") public void addActivityStream(final List<JSONObject> activities) { final JSONArray items = new JSONArray(); for (JSONObject activity : activities) { items.add(activity); } this.json.put("items", items); } }
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);
@SuppressWarnings({"unchecked", "rawtypes"}) private static void prepareGMTOffsetTimeZones() { for (String tzId : new String[]{"GMT-12:00", "GMT-11:00", "GMT-10:00", "GMT-09:00", "GMT-08:00", "GMT-07:00", "GMT-06:00", "GMT-05:00", "GMT-04:00", "GMT-03:00", "GMT-02:00", "GMT-01:00", "GMT+01:00", "GMT+02:00", "GMT+03:00", "GMT+04:00", "GMT+05:00", "GMT+06:00", "GMT+07:00", "GMT+08:00", "GMT+09:00", "GMT+10:00", "GMT+11:00", "GMT+12:00"}) { TimeZone tz = TimeZone.getTimeZone(tzId); JSONObject json = new JSONObject(); json.put(JsonTags.TIME_ZOME_DISPLAY_NAME, tz.getDisplayName(false, TimeZone.SHORT) + " (" + tzId + ")"); json.put(JsonTags.TIME_ZONE_ID, tzId); GMTOffsetTimeZones.add(json); } }