1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 package com.sun.star.sdbcx.comp.postgresql; 23 24 import java.util.List; 25 import java.util.Map; 26 27 import org.apache.openoffice.comp.sdbc.dbtools.comphelper.CompHelper; 28 import org.apache.openoffice.comp.sdbc.dbtools.sdbcx.OColumnContainer; 29 import org.apache.openoffice.comp.sdbc.dbtools.sdbcx.OContainer; 30 import org.apache.openoffice.comp.sdbc.dbtools.sdbcx.OIndexContainer; 31 import org.apache.openoffice.comp.sdbc.dbtools.sdbcx.OKey; 32 import org.apache.openoffice.comp.sdbc.dbtools.sdbcx.OKeyContainer; 33 import org.apache.openoffice.comp.sdbc.dbtools.sdbcx.OTable; 34 import org.apache.openoffice.comp.sdbc.dbtools.sdbcx.SqlTableHelper; 35 import org.apache.openoffice.comp.sdbc.dbtools.sdbcx.SqlTableHelper.ColumnDescription; 36 import org.apache.openoffice.comp.sdbc.dbtools.sdbcx.descriptors.SdbcxTableDescriptor; 37 38 import com.sun.star.beans.XPropertySet; 39 import com.sun.star.container.ElementExistException; 40 import com.sun.star.container.NoSuchElementException; 41 import com.sun.star.lang.IndexOutOfBoundsException; 42 import com.sun.star.sdbc.SQLException; 43 import com.sun.star.sdbc.XConnection; 44 45 public class PostgresqlTable extends OTable { PostgresqlTable(XConnection connection, OContainer tables, String name, String catalogName, String schemaName, String description, String type)46 public PostgresqlTable(XConnection connection, OContainer tables, String name, 47 String catalogName, String schemaName, String description, String type) { 48 super(name, true, connection, tables); 49 super.catalogName = catalogName; 50 super.schemaName = schemaName; 51 super.description = description; 52 super.type = type; 53 } 54 55 @Override createDataDescriptor()56 public XPropertySet createDataDescriptor() { 57 SdbcxTableDescriptor descriptor = new SdbcxTableDescriptor(true); 58 synchronized (this) { 59 CompHelper.copyProperties(this, descriptor); 60 } 61 return descriptor; 62 } 63 64 @Override setName(String name)65 public void setName(String name) { 66 // TODO Auto-generated method stub 67 68 } 69 70 @Override rename(String name)71 public void rename(String name) throws SQLException, ElementExistException { 72 // TODO Auto-generated method stub 73 74 } 75 76 @Override alterColumnByIndex(int index, XPropertySet descriptor)77 public void alterColumnByIndex(int index, XPropertySet descriptor) throws SQLException, IndexOutOfBoundsException { 78 // TODO Auto-generated method stub 79 80 } 81 82 @Override alterColumnByName(String name, XPropertySet descriptor)83 public void alterColumnByName(String name, XPropertySet descriptor) throws SQLException, NoSuchElementException { 84 // TODO Auto-generated method stub 85 86 } 87 88 @Override refreshColumns()89 protected OContainer refreshColumns() { 90 try { 91 List<ColumnDescription> columns = new SqlTableHelper().readColumns(getConnection().getMetaData(), catalogName, schemaName, getName()); 92 return new OColumnContainer(this, isCaseSensitive(), columns, this, getConnection().getMetaData()); 93 } catch (ElementExistException elementExistException) { 94 return null; 95 } catch (SQLException sqlException) { 96 return null; 97 } 98 } 99 100 @Override refreshIndexes()101 protected OContainer refreshIndexes() { 102 try { 103 List<String> indexes = new SqlTableHelper().readIndexes(getConnection().getMetaData(), catalogName, schemaName, getName(), this); 104 return new OIndexContainer(this, indexes, isCaseSensitive(), this); 105 } catch (ElementExistException elementExistException) { 106 return null; 107 } catch (SQLException sqlException) { 108 return null; 109 } 110 } 111 112 @Override refreshKeys()113 protected OContainer refreshKeys() { 114 try { 115 Map<String, OKey> keys = new SqlTableHelper().readKeys( 116 getConnection().getMetaData(), catalogName, schemaName, getName(), isCaseSensitive(), this); 117 return new OKeyContainer(this, isCaseSensitive(), keys, this); 118 } catch (ElementExistException elementExistException) { 119 return null; 120 } catch (SQLException sqlException) { 121 return null; 122 } 123 } 124 125 126 } 127