@Override public UpdateContainer doIt(VWorkspace vWorkspace) throws CommandException { Worksheet worksheet = vWorkspace.getViewFactory().getVWorksheet(vWorksheetId).getWorksheet(); Workspace ws = vWorkspace.getWorkspace(); if (worksheet.getSemanticTypes().getListOfTypes().size() == 0) { SemanticTypeUtil.populateSemanticTypesUsingCRF( worksheet, ws.getTagsContainer().getTag(TagName.Outlier), ws.getCrfModelHandler(), ws.getOntologyManager()); } WorksheetGeospatialContent geo = new WorksheetGeospatialContent(worksheet); // Send an error update if no geospatial data found! if (geo.hasNoGeospatialData()) { return new UpdateContainer(new ErrorUpdate("No geospatial data found in the worksheet!")); } try { final File file = geo.publishKML(); // Transfer the file to a public server final boolean transfer = transferFileToPublicServer(file); if (!transfer) { logger.error( "Published KML file could not be moved to a public server to display on Google Maps!"); } return new UpdateContainer( new AbstractUpdate() { @Override public void generateJson(String prefix, PrintWriter pw, VWorkspace vWorkspace) { JSONObject outputObject = new JSONObject(); try { outputObject.put(JsonKeys.updateType.name(), "PublishKMLUpdate"); outputObject.put(JsonKeys.fileName.name(), publicKMLAddress + file.getName()); outputObject.put(JsonKeys.transferSuccessful.name(), transfer); outputObject.put(JsonKeys.localFileName.name(), "KML/" + file.getName()); pw.println(outputObject.toString(4)); } catch (JSONException e) { logger.error("Error occured while generating JSON!"); } } }); } catch (FileNotFoundException e) { logger.error("KML File not found!", e); return new UpdateContainer(new ErrorUpdate("Error occurred while publishing KML layer!")); } }
@Override public UpdateContainer doIt(VWorkspace vWorkspace) throws CommandException { UpdateContainer c = new UpdateContainer(); Worksheet worksheet = vWorkspace.getViewFactory().getVWorksheet(vWorksheetId).getWorksheet(); worksheetName = worksheet.getTitle(); // Generate the semantic types for the worksheet OntologyManager ontMgr = vWorkspace.getWorkspace().getOntologyManager(); if (ontMgr.isEmpty()) return new UpdateContainer(new ErrorUpdate("No ontology loaded.")); SemanticTypeUtil.computeSemanticTypesForAutoModel( worksheet, vWorkspace.getWorkspace().getCrfModelHandler(), ontMgr); String alignmentId = AlignmentManager.Instance() .constructAlignmentId(vWorkspace.getWorkspace().getId(), vWorksheetId); Alignment alignment = AlignmentManager.Instance().getAlignment(alignmentId); if (alignment == null) { alignment = new Alignment(ontMgr); AlignmentManager.Instance().addAlignmentToMap(alignmentId, alignment); } try { // Save the semantic types in the input parameter JSON saveSemanticTypesInformation( worksheet, vWorkspace, worksheet.getSemanticTypes().getListOfTypes()); // Add the visualization update c.add(new SemanticTypesUpdate(worksheet, vWorksheetId, alignment)); c.add( new SVGAlignmentUpdate_ForceKarmaLayout( vWorkspace.getViewFactory().getVWorksheet(vWorksheetId), alignment)); } catch (Exception e) { logger.error("Error occured while generating the model Reason:.", e); return new UpdateContainer( new ErrorUpdate("Error occured while generating the model for the source.")); } c.add(new TagsUpdate()); return c; }