| | |
| | | package com.ximple.eofms.jobs; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.File; |
| | | import java.io.FilenameFilter; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FilenameFilter; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.ByteOrder; |
| | |
| | | import java.sql.Statement; |
| | | import java.sql.Types; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Iterator; |
| | | |
| | | import org.apache.commons.collections.OrderedMap; |
| | | import org.apache.commons.collections.OrderedMapIterator; |
| | | import org.apache.commons.collections.map.LinkedMap; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.quartz.JobDetail; |
| | | import org.quartz.JobExecutionContext; |
| | | import org.quartz.JobExecutionException; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.Envelope; |
| | | |
| | | import oracle.jdbc.OracleConnection; |
| | | import oracle.jdbc.OracleResultSet; |
| | |
| | | |
| | | import com.ximple.eofms.util.BinConverter; |
| | | import com.ximple.eofms.util.ByteArrayCompressor; |
| | | import com.ximple.eofms.util.TPCLIDConverter; |
| | | import com.ximple.eofms.util.StringUtils; |
| | | import com.ximple.io.dgn7.ComplexElement; |
| | | import com.ximple.io.dgn7.Dgn7fileException; |
| | | import com.ximple.io.dgn7.Dgn7fileReader; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.ElementType; |
| | | import com.ximple.io.dgn7.IElementHandler; |
| | | import com.ximple.io.dgn7.Dgn7fileReader; |
| | | import com.ximple.io.dgn7.Lock; |
| | | import com.ximple.io.dgn7.ComplexChainElement; |
| | | import com.ximple.io.dgn7.ComplexShapeElement; |
| | | import com.ximple.io.dgn7.TextNodeElement; |
| | | import com.ximple.io.dgn7.TextElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.util.PrintfFormat; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public class OracleConvertDgn2ShpJob extends AbstractOracleDatabaseJob |
| | | { |
| | | static Log logger = LogFactory.getLog(OracleConvertDgn2ShpJob.class); |
| | | final static Log logger = LogFactory.getLog(OracleConvertDgn2ShpJob.class); |
| | | |
| | | private static final int FETCHSIZE = 30; |
| | | private static final int BATCHSIZE = 25; |
| | |
| | | { |
| | | lastComplex = null; |
| | | |
| | | processElement(element, convertContext); |
| | | processIndexElement(element, convertContext); |
| | | } else if (element.isComponentElement()) |
| | | { |
| | | if (lastComplex != null) |
| | |
| | | lastComplex = element; |
| | | } else |
| | | { |
| | | processElement(element, convertContext); |
| | | processIndexElement(element, convertContext); |
| | | lastComplex = element; |
| | | } |
| | | } |
| | |
| | | logger.debug("ElementRecord Count=" + count); |
| | | } |
| | | |
| | | private void processElement(Element element, IndexDgnConvertJobContext convertContext) throws IllegalAttributeException, SchemaException |
| | | private void processIndexElement(Element element, IndexDgnConvertJobContext convertContext) throws IllegalAttributeException, SchemaException |
| | | { |
| | | if (element instanceof TextElement) |
| | | { |
| | |
| | | * °õ¦æÂà´«¨ä¥L³]p¹ÏÀɪº¤u§@ |
| | | * @param context |
| | | */ |
| | | private void convertOtherDesignFile(JobExecutionContext context) |
| | | private void convertOtherDesignFile(JobExecutionContext context) throws JobExecutionException |
| | | { |
| | | File otherDir = new File(getDataPath(), "other"); |
| | | if (!otherDir.exists()) |
| | |
| | | for (File dgnFile : dgnFiles) |
| | | { |
| | | GeneralDgnConvertJobContext convertContext = new GeneralDgnConvertJobContext(getDataPath()); |
| | | convertContext.setExecutionContext(context); |
| | | try |
| | | { |
| | | convertContext.setExecutionContext(context); |
| | | String dgnPaths[] = StringUtils.splitToArray(dgnFile.toString(), File.pathSeparator); |
| | | convertContext.setFilename(dgnPaths[dgnPaths.length - 1]); |
| | | |
| | | FileInputStream fs = new FileInputStream(dgnFile); |
| | | FileChannel fc = fs.getChannel(); |
| | | Dgn7fileReader reader = new Dgn7fileReader(fc, new Lock()); |
| | | convertContext.setReader(reader); |
| | | |
| | | scanOtherDgnElement(convertContext); |
| | | |
| | | convertContext.commitTransaction(); |
| | | } catch (FileNotFoundException e) |
| | | { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (Dgn7fileException e) |
| | | { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (IOException e) |
| | | { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (IllegalAttributeException e) |
| | | { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (SchemaException e) |
| | | { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void scanOtherDgnElement(GeneralDgnConvertJobContext convertContext) throws Dgn7fileException, IOException |
| | | public void scanOtherDgnElement(GeneralDgnConvertJobContext convertContext) |
| | | throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException |
| | | { |
| | | Dgn7fileReader reader = convertContext.getReader(); |
| | | int count = 0; |
| | |
| | | |
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | // @todo add process in here |
| | | lastComplex = null; |
| | | } |
| | | lastComplex = null; |
| | | |
| | | // @todo add process in here |
| | | processOtherElement(element, convertContext); |
| | | } else if (element.isComponentElement()) |
| | | { |
| | | if (lastComplex != null) |
| | |
| | | lastComplex = element; |
| | | } else |
| | | { |
| | | // @todo add process in here |
| | | processOtherElement(element, convertContext); |
| | | lastComplex = element; |
| | | } |
| | | } |
| | | |
| | | if (element.getElementType().isComplexElement()) |
| | | { |
| | | if (element instanceof ComplexChainElement) |
| | | { |
| | | ComplexChainElement complexChain = (ComplexChainElement) element; |
| | | int size = complexChain.size(); |
| | | for (Object aComplexChain : complexChain) |
| | | { |
| | | Element subElement = (Element) aComplexChain; |
| | | subElement.getType(); |
| | | } |
| | | } |
| | | |
| | | if (element instanceof ComplexShapeElement) |
| | | { |
| | | ComplexShapeElement complexShape = (ComplexShapeElement) element; |
| | | } |
| | | |
| | | if (element instanceof TextNodeElement) |
| | | { |
| | | TextNodeElement textNode = (TextNodeElement) element; |
| | | int size = textNode.size(); |
| | | for (int i = 0; i < size; i++) |
| | | { |
| | | Element subElement = (Element) textNode.get(i); |
| | | subElement.getElementType(); |
| | | } |
| | | } |
| | | |
| | | } else |
| | | { |
| | | boolean hasLinkage = false; |
| | | if (element instanceof TextElement) |
| | | { |
| | | TextElement textElm = (TextElement) element; |
| | | List<UserAttributeData> usrData = textElm.getUserAttributeData(); |
| | | Iterator<UserAttributeData> it = usrData.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | UserAttributeData attr = it.next(); |
| | | if (attr instanceof FrammeAttributeData) |
| | | { |
| | | hasLinkage = true; |
| | | System.out.println("------------------------------------------"); |
| | | System.out.println("FSC=" + ((FrammeAttributeData) attr).getFsc() + ":" + |
| | | ((FrammeAttributeData) attr).getUfid()); |
| | | } |
| | | } |
| | | |
| | | if (hasLinkage) |
| | | { |
| | | System.out.println("Text.Font=" + textElm.getFontIndex()); |
| | | System.out.println("Text.Just=" + textElm.getJustification()); |
| | | System.out.println("usrData.len=" + usrData.size()); |
| | | System.out.println("text=" + textElm.getText()); |
| | | System.out.println("Origin=" + textElm.getOrigin()); |
| | | System.out.println("UserOrigin=" + textElm.getUserOrigin()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | count++; |
| | | } |
| | | |
| | | logger.info("ElementRecord Count=" + count); |
| | | logger.debug("ElementRecord Count=" + count); |
| | | } |
| | | |
| | | private void processOtherElement(Element element, GeneralDgnConvertJobContext convertContext) throws IllegalAttributeException, SchemaException |
| | | { |
| | | if (element instanceof TextElement) |
| | | { |
| | | convertContext.putFeatureCollection(element); |
| | | } |
| | | } |
| | | } |