/
SpatialIsClosedMethod2.java
71 lines (60 loc) · 2.71 KB
/
SpatialIsClosedMethod2.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**********************************************************************
Copyright (c) 2009 Andy Jefferson and others. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Contributors:
...
**********************************************************************/
package org.datanucleus.store.types.geospatial.rdbms.sql.method;
import java.util.ArrayList;
import java.util.List;
import org.datanucleus.exceptions.NucleusUserException;
import org.datanucleus.store.types.geospatial.rdbms.sql.expression.GeometryExpression;
import org.datanucleus.store.rdbms.sql.expression.SQLExpression;
import org.datanucleus.store.rdbms.sql.method.AbstractSQLMethod;
/**
* Implementation of "Spatial.isClosed(expr)" or "{expr}.isClosed()" method for Oracle.
*/
public class SpatialIsClosedMethod2 extends AbstractSQLMethod
{
/*
* (non-Javadoc)
* @see
* org.datanucleus.store.rdbms.sql.method.SQLMethod#getExpression(org.datanucleus.store.rdbms.sql.expression
* .SQLExpression, java.util.List)
*/
public SQLExpression getExpression(SQLExpression expr, List args)
{
if (expr == null && (args == null || args.size() != 1))
{
throw new NucleusUserException("Cannot invoke Spatial.isClosed without 1 argument");
}
else if (expr != null && args != null && args.size() != 0)
{
throw new NucleusUserException("Cannot invoke geom.isClosed() with an argument");
}
SQLExpression argExpr = expr;
if (expr == null)
{
argExpr = (SQLExpression) args.get(0);
}
ArrayList geomFuncArgs = new ArrayList();
geomFuncArgs.add(argExpr);
GeometryExpression geomExpr = new GeometryExpression(stmt, null, "geometry.from_sdo_geom", geomFuncArgs, null);
ArrayList treatFuncArgs = new ArrayList();
treatFuncArgs.add(geomExpr);
ArrayList treatFuncTypeArgs = new ArrayList();
treatFuncTypeArgs.add("curve");
GeometryExpression treatExpr = new GeometryExpression(stmt, null, "treat", treatFuncArgs, treatFuncTypeArgs);
ArrayList funcArgs = new ArrayList();
funcArgs.add(treatExpr);
return SpatialMethodHelper.getBooleanExpression(stmt, "isClosed", funcArgs, exprFactory);
}
}