01-08-2016
05:29 AM
- last edited on
01-15-2016
12:44 AM
by
tanzinge
Hi all,
a few days ago I wrote you about the need to add a feature to the legend using java API.
Thanks of your advices I could do that, but I still have two questions for you:
Caused by: com.intergraph.web.viewer.map.style.SymbologyConfigurationException: Can't find style '68f9c52d-ef9b-4c60-a854-37872ca3106e' in directory: C:\ProgramData\Intergraph\SmartClient\cache\GMSC\_symbology_\prj_DWH_Nitrati_library at com.intergraph.web.viewer.map.style.GFeatureTypeStyleManager.getStylePath(GFeatureTypeStyleManager.java:237) at com.intergraph.web.viewer.map.style.GFeatureTypeStyleManager.readStyleFromCache(GFeatureTypeStyleManager.java:179) at com.intergraph.web.viewer.map.style.GFeatureTypeStyleManager.loadStyle(GFeatureTypeStyleManager.java:119) at com.intergraph.web.viewer.map.style.GFeatureTypeStyleManager.getStyle(GFeatureTypeStyleManager.java:110) at com.intergraph.web.viewer.reader.gdoplus.GDOPlusFactory.getFeatureTypeStyle(GDOPlusFactory.java:180) at com.intergraph.web.viewer.reader.gdoplus.StyleGroup.createStyleGroup(StyleGroup.java:49)
Someone knows how I can add the style to the cache.
This is my complete code to understand better:
public boolean publishTheme(String symbologyIds, String symbologyNames, int simpleId, String name, String projectName, String entity, String themeName, int level) { try { Project project = ApplicationContext.getProject(); Theme myTheme = project.getThemeByName(themeName); if (myTheme == null) { myTheme = Theme.createTheme(themeName, false, false); project.addThemeToProject(null, myTheme); } myTheme.setClosed(false); //tiling com.intergraph.services.emea._2011._03.types.TilingInfo ti = new com.intergraph.services.emea._2011._03.types.TilingInfo(); ti.setColumns(1); ti.setRows(1); //scale range com.intergraph.services.emea._2011._03.types.ScaleRange sr = new com.intergraph.services.emea._2011._03.types.ScaleRange(); sr.setFrom(new Long(0)); sr.setTo(new Long(1000000000)); //symbolgy com.intergraph.services.emea._2011._03.types.ArrayOfDisplayRule listDr = new com.intergraph.services.emea._2011._03.types.ArrayOfDisplayRule(); String[] symbologyIdsArray = symbologyIds.split("#"); String[] symbologyNamesArray = symbologyNames.split("#"); for(int i = 0; i < symbologyIdsArray.length; i++) { com.intergraph.services.emea._2011._03.types.DisplayRule dr = new com.intergraph.services.emea._2011._03.types.DisplayRule(); dr.setName(symbologyNamesArray[i]); dr.setSymbologyId(symbologyIdsArray[i]); listDr.getDisplayRule().add(dr); } com.intergraph.services.emea._2011._03.types.Feature feature = new com.intergraph.services.emea._2011._03.types.Feature(); feature.setId(simpleId); feature.setName(name); feature.setDescription(name); feature.setGeometryType(GeometryTypes.AREA); feature.setMapInterpretaionType(MapInterpretationTypes.DEFAULT); feature.setKeyAttribute(key); feature.setTilingInfo(ti); feature.setBoundingBox(getBounds()); feature.setScaleRange(sr); feature.setDisplayRules(listDr); feature.setFitFactor(new Float(1.25)); feature.setOpacity(new Float(1)); java.util.Date date= new java.util.Date(); feature.setPublishTimestamp(new Timestamp(date.getTime()).getTime()); feature.setLoaderId(loaderId); feature.setRightOnFeature(FeatureRight.ANALYZE); feature.setCopyright(""); feature.setDataProjectName(projectName); feature.setIsSnapable(true); feature.setEntity(entity); project.addFeature(feature, myTheme, level); return true; } catch (Exception e) { // TODO Auto-generated catch block GUIToolkit.showInfo("Ex: " + e.getMessage()); Log.getLogger().log(Level.SEVERE, e.getMessage(), e); return false; } }
Thanks all
Azzurra
01-11-2016 01:50 AM
Hi,
when you update the SymbologyLibrary in your workflow (add or modify a style), do you also update the timestamp?
The library will only be downloaded again on the client side, if the timestamps do not match. Also be aware of the fact that the libraries are downloaded on startup so if you add a style to the library using Workflows, you have to call
GFeatureTypeStyleManager.reloadSymbologyLibraries()
to actually get the new style at runtime.
To update the timestamp for the library in your Workflow you have to add these lines to your code (replace {YOURLIBRARY_ID} accordingly):
string symbologyLibraryId = {YOURLIBRARY_ID}; database.ExecuteNonQuery("Update RPI_SYMBOLOGYLIBRARY Set LIBRARYTIMESTAMP = @LIBRARYTIMESTAMP Where ID = @ID", new List<DataParameter>(){new DataParameter("LIBRARYTIMESTAMP", (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds), new DataParameter("ID", symbologyLibraryId)});
Regards
Thomas
01-11-2016 02:13 AM
Thanks a lot Thomas.
I'm going to try
Azzurra
01-13-2016 01:30 AM
Hi Thomas,
following your advice I can resolve the point 2, but not the point 1.
In the picture you can view the difference between a feature added using the administrator tools and one added by the code.
Someone can help me?
Thanks
Azzurra
01-13-2016 07:30 AM
We have just reproduced the behavior and figured out that this is a Bug. While the feature is added as expected, the display rules are not handled in the legend when you use this method. Unfortunately there is no workaround that we can offer so you must wait until it is fixed in the product itself.
Alternatively you can create multiple features and add them to one theme instead of creating a thematic legend entry
Please report this bug in Siebel (https://siebweb.intergraph.com/service_enu/start.swe).