Package org.geoforge.mdldatogc

Source Code of org.geoforge.mdldatogc.GfrMdlDatIdObjTloOgcWms

/*
*  Copyright (C) 2011-2014 GeoForge Project
*
*  This program is free software; you can redistribute it and/or
*  modify it under the terms of the GNU Lesser General Public License
*  as published by the Free Software Foundation; either version 2
*  of the License, or (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU Lesser General Public License for more details.
*
*  You should have received a copy of the GNU Lesser General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package org.geoforge.mdldatogc;

import java.io.File;
import java.util.ArrayList;
import org.geoforge.bsoogc.boundingbox.GfrBbxLyrImgWms;
import org.geoforge.java.io.file.GfrUtilFile;
import org.geoforge.mdldat.event.GfrEvtMdlIdDatAddedLloVarImg;
import org.geoforge.mdldat.event.GfrEvtMdlIdDatRemovedAllLloImgs;
import org.geoforge.mdldat.event.GfrEvtMdlIdDatRemovedLloVarImg;
import org.geoforge.mdldat.event.GfrEvtMdlIdDatRenamedLloVar;
import org.geoforge.mdldatogc.event.*;
import org.geoforge.wrpbasprssynogc.GfrWrpBasSynObjNameTloWms;

/**
*
* @author bantchao
*/
public class GfrMdlDatIdObjTloOgcWms extends GfrMdlDatIdObjTloOgcAbs
{
   static private GfrMdlDatIdObjTloOgcWms _INSTANCE_ = null;

   static public GfrMdlDatIdObjTloOgcWms getInstance()
   {
      if (GfrMdlDatIdObjTloOgcWms._INSTANCE_ == null)
         GfrMdlDatIdObjTloOgcWms._INSTANCE_ = new GfrMdlDatIdObjTloOgcWms();

      return GfrMdlDatIdObjTloOgcWms._INSTANCE_;
   }
  
   // end static
  
   // beg legends folder
   public void renameImageLegendLayerFolder(String strIdChild, String strNameNew, String strIdParent) throws Exception
   {
      GfrWrpBasSynObjNameTloWms.getInstance().renameImageLegendLayerFolder(strIdChild, strNameNew);
     
      super.setChanged();
      Object obj = new GfrEvtMdlIdDatRenamedLloVar(strIdChild, strNameNew, strIdParent);
      super.notifyObservers(obj);
   }

   // !!! at most one legend per layer
   public void deleteAllImagesLegendLayerFolder(String strIdThis) throws Exception
  
      String[] strsIdImage = GfrWrpBasSynObjNameTloWms.getInstance().getIdsImageLegendLayerFolder(strIdThis);
     
      try
      {
         for (int i=0; i<strsIdImage.length; i++)
         {
            String strPathAbsChild = GfrWrpBasSynObjNameTloWms.getInstance().getPathAbsoluteImageFile(strsIdImage[i]);
            GfrUtilFile.s_delete(new File(strPathAbsChild));
         }
      }
     
      catch(Exception exc)
      {
         exc.printStackTrace();
         // TODO: ?delete file at exit time.
        
         // ---
         throw exc;
      }

      GfrWrpBasSynObjNameTloWms.getInstance().deleteAllImagesLegendLayerFolder(strIdThis);
     
      super.setChanged();
      Object objMrk = new GfrEvtMdlIdDatRemovedAllLloImgs(strIdThis);
      super.notifyObservers(objMrk);
   }

   public void deleteImageLegendLayerFolder(String strIdThis, String strIdChild) throws Exception
   {
      GfrWrpBasSynObjNameTloWms.getInstance().deleteImageLegendLayerFolder(strIdChild);
      try
      {
         String strPathAbsChild = GfrWrpBasSynObjNameTloWms.getInstance().getPathAbsoluteImageFile(strIdChild);
         GfrUtilFile.s_delete(new File(strPathAbsChild));
      }
     
      catch(Exception exc)
      {
         exc.printStackTrace();
         // TODO: ?delete file at exit time.
        
         // ---
         throw exc;
      }
     
      super.setChanged();
      Object obj = new GfrEvtMdlIdDatRemovedLloVarImg(strIdChild, strIdThis);
      super.notifyObservers(obj);
   }

   public String newObjectImageLegendLayerFolder(String strIdParent, String strNameChild, String strPathAbsSource) throws Exception
   {
      String strIdChild = GfrWrpBasSynObjNameTloWms.getInstance().saveImageLegendLayerFolder(strIdParent, strNameChild);
     
      File fleOut = null;
     
      try
      {
        
         File fleIn = new File(strPathAbsSource);
         String strPathAbsOut = GfrWrpBasSynObjNameTloWms.getInstance().getPathAbsoluteImageFile(strIdChild);
         fleOut = new File(strPathAbsOut);
     
         GfrUtilFile.s_copy(fleIn, fleOut);
      }
     
      catch(Exception exc)
      {
         exc.printStackTrace();
         GfrWrpBasSynObjNameTloWms.getInstance().deleteImageLegendLayerFolder(strIdChild);
        
         if (fleOut != null)
         {
            if (fleOut.isFile() && fleOut.exists())
               fleOut.delete();
         }
        
         // ---
         throw exc;
      }
     
      super.setChanged();
      Object obj = new GfrEvtMdlIdDatAddedLloVarImg(strIdChild, strIdParent);
      super.notifyObservers(obj);
     
      return strIdChild;
   }
  
   // end legends folder
  
   // beg legends leaf
   public void renameImageLegendLayerLeaf(String strIdChild, String strNameNew, String strIdParent) throws Exception
   {
      GfrWrpBasSynObjNameTloWms.getInstance().renameImageLegendLayerLeaf(strIdChild, strNameNew);
     
      super.setChanged();
      Object obj = new GfrEvtMdlIdDatRenamedLloVar(strIdChild, strNameNew, strIdParent);
      super.notifyObservers(obj);
   }

   // !!! at most one legend per layer
   public void deleteAllImagesLegendLayerLeaf(String strIdThis) throws Exception
  
      String[] strsIdImage = GfrWrpBasSynObjNameTloWms.getInstance().getIdsImageLegendLayerLeaf(strIdThis);
     
      try
      {
         for (int i=0; i<strsIdImage.length; i++)
         {
            String strPathAbsChild = GfrWrpBasSynObjNameTloWms.getInstance().getPathAbsoluteImageFile(strsIdImage[i]);
            GfrUtilFile.s_delete(new File(strPathAbsChild));
         }
      }
     
      catch(Exception exc)
      {
         exc.printStackTrace();
         // TODO: ?delete file at exit time.
        
         // ---
         throw exc;
      }

      GfrWrpBasSynObjNameTloWms.getInstance().deleteAllImagesLegendLayerLeaf(strIdThis);
     
      super.setChanged();
      Object objMrk = new GfrEvtMdlIdDatRemovedAllLloImgs(strIdThis);
      super.notifyObservers(objMrk);
   }

   public void deleteImageLegendLayerLeaf(String strIdThis, String strIdChild) throws Exception
   {
      GfrWrpBasSynObjNameTloWms.getInstance().deleteImageLegendLayerLeaf(strIdChild);
      try
      {
         String strPathAbsChild = GfrWrpBasSynObjNameTloWms.getInstance().getPathAbsoluteImageFile(strIdChild);
         GfrUtilFile.s_delete(new File(strPathAbsChild));
      }
     
      catch(Exception exc)
      {
         exc.printStackTrace();
         // TODO: ?delete file at exit time.
        
         // ---
         throw exc;
      }
     
      super.setChanged();
      Object obj = new GfrEvtMdlIdDatRemovedLloVarImg(strIdChild, strIdThis);
      super.notifyObservers(obj);
   }

   public String newObjectImageLegendLayerLeaf(String strIdParent, String strNameChild, String strPathAbsSource) throws Exception
   {
      String strIdChild = GfrWrpBasSynObjNameTloWms.getInstance().saveImageLegendLayerLeaf(strIdParent, strNameChild);
     
      File fleOut = null;
     
      try
      {
        
         File fleIn = new File(strPathAbsSource);
         String strPathAbsOut = GfrWrpBasSynObjNameTloWms.getInstance().getPathAbsoluteImageFile(strIdChild);
         fleOut = new File(strPathAbsOut);
     
         GfrUtilFile.s_copy(fleIn, fleOut);
      }
     
      catch(Exception exc)
      {
         exc.printStackTrace();
         GfrWrpBasSynObjNameTloWms.getInstance().deleteImageLegendLayerLeaf(strIdChild);
        
         if (fleOut != null)
         {
            if (fleOut.isFile() && fleOut.exists())
               fleOut.delete();
         }
        
         // ---
         throw exc;
      }
     
      super.setChanged();
      Object obj = new GfrEvtMdlIdDatAddedLloVarImg(strIdChild, strIdParent);
      super.notifyObservers(obj);
     
      return strIdChild;
   }
  
   // end legends leaf
  
  
   // beg public
  
   // used by treeNodes
   public void doneTreeArborescence(String strIdTLo) throws Exception
   {
      // GfrEvtMdlIdDoneTreeArborWms
      super.setChanged();
     
      Object obj = new GfrEvtMdlIdDoneTreeArborWms(strIdTLo);
     
      super.notifyObservers(obj);
   }
  
   public void setParentFolderIdLayerFolder(
           String strIdLayerFolder,
           String strIdLayerParentFolder) throws Exception
   {
      GfrWrpBasSynObjNameTloWms.getInstance().setParentFolderIdLayerFolder(
              strIdLayerFolder,
              strIdLayerParentFolder );
   }
  
   public String newObjectLayerFolder(
           String strIdThis,
           String strValueNameLayer,
           String strValueTitleLayer,
           String strValueAbstractLayer,
           String strValueStylesLayer,
           String strValueLegendUrlLayer,
           ArrayList<GfrBbxLyrImgWms> altBbx)
           throws Exception
   {
      String strIdChild = GfrWrpBasSynObjNameTloWms.getInstance().saveLayerFolder(
              strIdThis,
              strValueNameLayer,
              strValueTitleLayer,
              strValueAbstractLayer,
              strValueStylesLayer,
              strValueLegendUrlLayer,
              altBbx);
     
     
     /* super.setChanged();
     
      Object obj = new GfrEvtMdlIdDatAddedLloVarWmsLyrLeaf(strIdChild, strIdThis,
              strValueLayerNames,
              strValueDisplayName, strValueLayerAbstract, strValueStyleNames);
     
      super.notifyObservers(obj);*/
     
      return strIdChild;
   }
  
   public void setParentFolderIdLayerLeaf(
           String strIdLayerLeaf,
           String strIdLayerParentFolder) throws Exception
   {
      GfrWrpBasSynObjNameTloWms.getInstance().setParentFolderIdLayerLeaf(
              strIdLayerLeaf,
              strIdLayerParentFolder );
   }
  
  
  
  
   public String newObjectLayerLeaf(
           String strIdThis,
           String strValueNameLayer,
           String strValueTitleLayer,
           String strValueAbstractLayer,
           String strValueStylesLayer,
           String strValueLegendUrlLayer,
           ArrayList<GfrBbxLyrImgWms> altBbx,
           boolean blnIsKindScaleDenominator,
           double dblMinScale,
           double dblMaxScale)
           throws Exception
   {
      String strIdChild = GfrWrpBasSynObjNameTloWms.getInstance().saveLayerLeaf(
              strIdThis, strValueNameLayer,
              strValueTitleLayer, strValueAbstractLayer, strValueStylesLayer, strValueLegendUrlLayer,
              altBbx, blnIsKindScaleDenominator, dblMinScale, dblMaxScale);
     
    
      super.setChanged();
     
      Object obj = new GfrEvtMdlIdDatAddedLloVarWmsLyrLeaf(strIdChild, strIdThis,
              strValueNameLayer,
              strValueTitleLayer,
              strValueAbstractLayer,
              strValueStylesLayer);
     
      super.notifyObservers(obj);
     
      return strIdChild;
   }
  
 
   /*public void deleteLayerLeaf(String strIdThis, String strIdChild)
           throws Exception
   {
      GfrWrpBasSynObjNameTloWms.getInstance().deleteLayerLeaf(strIdChild);
     
      super.setChanged();
      Object obj = new GfrEvtMdlIdDatRemovedLloVarLyrWms(strIdChild, strIdThis);
      super.notifyObservers(obj);
   }*/
  
 
   /*public void deleteAllLayersLeaves(String strIdThis) throws Exception
   {
      GfrWrpBasSynObjNameTloWms.getInstance().deleteAllLayersLeaves(strIdThis);
     
      super.setChanged();
      Object obj = new GfrEvtMdlIdDatRemovedAllLloLyrsWms(strIdThis);
      super.notifyObservers(obj);
   }*/
  
   // ---
  
   public String newObjectTerrain(
           String strIdThis,
           String strValueLayerNames,
           String strValueDisplayName,
           String strValueLayerAbstract,
           String strValueStyleNames)
           throws Exception
   {
      String strIdChild = GfrWrpBasSynObjNameTloWms.getInstance().saveTerrain(strIdThis, strValueLayerNames,
              strValueDisplayName, strValueLayerAbstract, strValueStyleNames);
     
     
      super.setChanged();
     
      Object obj = new GfrEvtMdlIdDatAddedLloVarWmsTer(strIdChild, strIdThis,
              strValueLayerNames,
              strValueDisplayName, strValueLayerAbstract, strValueStyleNames);
     
      super.notifyObservers(obj);
     
      return strIdChild;
   }
  
 
   /*public void deleteTerrain(String strIdThis, String strIdChild)
           throws Exception
   {
      GfrWrpBasSynObjNameTloWms.getInstance().deleteTerrain(strIdChild);
     
      super.setChanged();
      Object obj = new GfrEvtMdlIdDatRemovedLloVarTerWms(strIdChild, strIdThis);
      super.notifyObservers(obj);
   }*/
  
 
   /*public void deleteAllTerrains(String strIdThis) throws Exception
   {
      GfrWrpBasSynObjNameTloWms.getInstance().deleteAllTerrains(strIdThis);
     
      super.setChanged();
      Object obj = new GfrEvtMdlIdDatRemovedAllLloTersWms(strIdThis);
      super.notifyObservers(obj);
   }*/
  
   // beg private
  
   private GfrMdlDatIdObjTloOgcWms()
   {
      super();
   }
  
}
TOP

Related Classes of org.geoforge.mdldatogc.GfrMdlDatIdObjTloOgcWms

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.