631 |
631 |
|
632 |
632 |
private void oneRowMetadata() {
|
633 |
633 |
try {
|
634 |
|
String _sql = "select " + getStandardSelectExpression() + ", c." +
|
635 |
|
geoColName + " from " + getTableName() + " c ";
|
636 |
634 |
|
637 |
635 |
st = ((ConnectionJDBC)conn).getConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
|
638 |
636 |
ResultSet.CONCUR_READ_ONLY);
|
639 |
|
|
640 |
|
ResultSet _rs = st.executeQuery(_sql + " where c." + geoColName + " is not NULL AND rownum = 1");
|
641 |
|
|
642 |
|
if (_rs.next()) {
|
643 |
|
STRUCT sample_geo = (STRUCT) _rs.getObject(geoColName);
|
644 |
|
shapeType = OracleSpatialUtils.getShapeTypeOfStruct(sample_geo);
|
645 |
|
}
|
646 |
|
else {
|
647 |
|
shapeType = FShape.MULTI;
|
648 |
|
}
|
649 |
|
|
|
637 |
|
|
638 |
ResultSet _rs = null;
|
|
639 |
shapeType = guessShapeType();
|
650 |
640 |
// -----------------------
|
651 |
641 |
_rs = st.executeQuery(not_restricted_sql + " where (rownum = 1)");
|
652 |
642 |
metaData = _rs.getMetaData();
|
653 |
|
|
654 |
643 |
userName = ((ConnectionJDBC)conn).getConnection().getMetaData().getUserName();
|
655 |
644 |
|
656 |
645 |
// geoColInd = _rs.findColumn(geoColName);
|
... | ... | |
667 |
656 |
}
|
668 |
657 |
|
669 |
658 |
getIdFieldNames();
|
670 |
|
|
671 |
659 |
adjustLyrDef();
|
672 |
|
|
673 |
660 |
_rs.close(); // st no debe cerrarse ya que las llamadas a metadata lo encesitan
|
674 |
661 |
}
|
675 |
662 |
catch (SQLException se) {
|
... | ... | |
677 |
664 |
}
|
678 |
665 |
}
|
679 |
666 |
|
|
667 |
private int guessShapeType() {
|
680 |
668 |
|
|
669 |
int resp = FShape.MULTI;
|
681 |
670 |
|
682 |
|
private String getIdFieldNames() {
|
|
671 |
String _sql = "select " + getStandardSelectExpression() + ", c." +
|
|
672 |
geoColName + " from " + getTableName() + " c ";
|
|
673 |
|
|
674 |
ResultSet _rs = null;
|
|
675 |
STRUCT sample_geo = null;
|
|
676 |
|
683 |
677 |
try {
|
|
678 |
_sql = _sql + " where c." + geoColName + " is not NULL AND "
|
|
679 |
+ OracleSpatialUtils.EXPONENTIAL_INDICES_CONDITION;
|
|
680 |
|
|
681 |
_rs = st.executeQuery(_sql);
|
|
682 |
|
|
683 |
int aux = 0;
|
|
684 |
ArrayList shptypes = new ArrayList();
|
|
685 |
while (_rs.next()) {
|
|
686 |
sample_geo = (STRUCT) _rs.getObject(geoColName);
|
|
687 |
aux = OracleSpatialUtils.getShapeTypeOfStruct(sample_geo);
|
|
688 |
shptypes.add(new Integer(aux));
|
|
689 |
}
|
|
690 |
if (shptypes.size() > 0) {
|
|
691 |
resp = getShapeTypeFromArray(shptypes);
|
|
692 |
}
|
|
693 |
} catch (Exception ex) {
|
|
694 |
logger.error("While guessing shape type: " + ex.getMessage());
|
|
695 |
logger.warn("Assumed MULTI");
|
|
696 |
}
|
|
697 |
|
|
698 |
return resp;
|
|
699 |
}
|
|
700 |
|
|
701 |
private int getShapeTypeFromArray(ArrayList arrlist) {
|
|
702 |
|
|
703 |
int resp = ((Integer) arrlist.get(0)).intValue();
|
|
704 |
|
|
705 |
int sz = arrlist.size();
|
|
706 |
int aux = 0;
|
|
707 |
for (int i=1; i<sz; i++) {
|
|
708 |
aux = ((Integer) arrlist.get(i)).intValue();
|
|
709 |
if (aux != resp) return FShape.MULTI;
|
|
710 |
}
|
|
711 |
return resp;
|
|
712 |
}
|
|
713 |
|
|
714 |
private String getIdFieldNames() {
|
|
715 |
try {
|
684 |
716 |
idFieldNames = "";
|
685 |
717 |
|
686 |
718 |
for (int i = 0; i < pkOneBasedIndexes.length; i++) {
|