Package org.geoforge.wrpbasprsdatecl

Source Code of org.geoforge.wrpbasprsdatecl.GfrWrpBasTopDatEclSegsWiseYes

/*
*  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.wrpbasprsdatecl;

import java.awt.geom.Point2D;
import java.util.ArrayList;
import org.geoforge.basprjdat.table.object.GfrBasTblDatObjAbs;
import org.geoforge.basprjdat.table.object.GfrBasTblDatTloAbs;
import org.geoforge.basprjdat.table.object.GfrBasTblDatXloAbs;
import org.geoforge.basprjdatecl.table.objects.GfrBasTblDatChildNameImgSegWiseYes;
import org.geoforge.basprjdatecl.table.objects.GfrBasTblDatTloSegWiseYesEcl;
import org.geoforge.java.awt.geom.GfrUtilPoint2D;
import org.geoforge.lang.util.arraylist.GfrAltPointDouble;
import org.geoforge.java.lang.string.GfrUtlString;
import org.geoforge.sql.field.GfrFldAbs;

/**
*
* @author Amadeus.Sowerby
*
* email: Amadeus.Sowerby_AT_gmail.com ... please remove "_AT_" from the above
* string to get the right email address
*/
abstract public class GfrWrpBasTopDatEclSegsWiseYes extends GfrWrpBasTopDatEclAbs
{

   protected String[] _getSortedNames(String strPathAbsDbDtaProject) throws Exception
   {
      return super._getSortedNames(
            strPathAbsDbDtaProject,
            GfrBasTblDatTloSegWiseYesEcl.s_getInstance());
   }

   /*
    * returns unique ID
    */
   protected String _save(
         String strPathAbsDbDtaProject,
         String strName,
         String strDescShort,
         String strUrl,
         Point2D.Double p2dPointStart,
         Point2D.Double p2dPointEnd)
         throws Exception
   {
      GfrBasTblDatObjAbs tblObject = GfrBasTblDatTloSegWiseYesEcl.s_getInstance();

      String strIdObj = GfrUtlString.s_getUniqueId(tblObject.getName());

      GfrFldAbs[] flds =
      {
         GfrBasTblDatObjAbs.FLD_VAR_CHAR_ID_OBJ,
         GfrBasTblDatTloAbs.FLD_VAR_CHAR_NAME,
         GfrBasTblDatXloAbs.FLD_VAR_CHAR_DESCRIPTION,
         GfrBasTblDatTloAbs.FLD_VAR_CHAR_URL,
         GfrBasTblDatTloSegWiseYesEcl.FLD_VAR_CHAR_POINT_START,
         GfrBasTblDatTloSegWiseYesEcl.FLD_VAR_CHAR_POINT_END
      };

      String[] strs =
      {
         strIdObj,
         strName,
         strDescShort,
         strUrl,
         GfrUtilPoint2D.s_toString(p2dPointStart),
         GfrUtilPoint2D.s_toString(p2dPointEnd)
      };

      super._save(
            strPathAbsDbDtaProject,
            tblObject,
            flds,
            strs,
            strIdObj);

      return strIdObj;
   }

   //--never called for now
   protected String[] _save(
         String strPathAbsDbDtaThis,
         String[] strsName,
         String[] strsDescShort,
         String[] strsUrl,
         Point2D.Double[] p2dsStart,
         Point2D.Double[] p2dsEnd)
         throws Exception
   {

      if (strsName == null || strsName.length < 1)
         throw new Exception("Inserting corrupted data in db :\n strsName == null || strsName.length <1");

      if (strsDescShort == null || strsDescShort.length < 1)
         throw new Exception("Inserting corrupted data in db :\n strsDescShort == null || strsDescShort.length <1");

      if (strsUrl == null || strsUrl.length < 1)
         throw new Exception("Inserting corrupted data in db :\n strsUrl == null || strsUrl.length <1");

      if (p2dsStart == null || p2dsStart.length < 1)
         throw new Exception("Inserting corrupted data in db :\n p2dsStart == null || p2dsStart.length <1");

      if (p2dsEnd == null || p2dsEnd.length < 1)
         throw new Exception("Inserting corrupted data in db :\n p2dsEnd == null || p2dsEnd.length <1");

     
      if (strsName.length != strsDescShort.length
            || strsDescShort.length != strsUrl.length
            || strsUrl.length != p2dsStart.length
            || p2dsStart.length != p2dsEnd.length)
         throw new Exception("Trying to insert corrupted dataset in db");

      GfrBasTblDatObjAbs tblObject = GfrBasTblDatTloSegWiseYesEcl.s_getInstance();

      GfrFldAbs[] flds =
      {
         GfrBasTblDatObjAbs.FLD_VAR_CHAR_ID_OBJ,
         GfrBasTblDatTloAbs.FLD_VAR_CHAR_NAME,
         GfrBasTblDatXloAbs.FLD_VAR_CHAR_DESCRIPTION,
         GfrBasTblDatTloAbs.FLD_VAR_CHAR_URL,
         GfrBasTblDatTloSegWiseYesEcl.FLD_VAR_CHAR_POINT_START,
         GfrBasTblDatTloSegWiseYesEcl.FLD_VAR_CHAR_POINT_END
      };


      int intSize = strsUrl.length;

      String[] strsIds = new String[intSize];
      ArrayList<String[]> altStrs = new ArrayList<String[]>();


      for (int i = 0; i < intSize; i++)
      {
         String strIdObj = GfrUtlString.s_getUniqueId(tblObject.getName());

         strsIds[i] = strIdObj;

         String[] strsCur =
         {
            strIdObj,
            strsName[i],
            strsDescShort[i],
            strsUrl[i],
            GfrUtilPoint2D.s_toString(p2dsStart[i]),
            GfrUtilPoint2D.s_toString(p2dsEnd[i])
         };

         altStrs.add(strsCur);

      }

      super._save(
            strPathAbsDbDtaThis,
            tblObject,
            flds,
            altStrs,
            strsIds);

      return strsIds;
   }

   @Override
   public void deleteAllTlos() throws Exception
   {
      super._deleteAll(GfrBasTblDatChildNameImgSegWiseYes.s_getInstance()); // !!! TO BE CHECKED

      GfrBasTblDatObjAbs tblObject = GfrBasTblDatTloSegWiseYesEcl.s_getInstance();

      if (!super.isNotEmpty())
         return;

      super._deleteAll(tblObject);
   }

   // avoid instantiation
   protected GfrWrpBasTopDatEclSegsWiseYes()
   {
   }
}
TOP

Related Classes of org.geoforge.wrpbasprsdatecl.GfrWrpBasTopDatEclSegsWiseYes

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.