/** * Adds a new dimension. * * @param name * the name of the dimension, never <code>null</code> * @param values * the values of the dimension, never <code>null</code> */ public void addDimensionValue( String name, List<?> values ) { dimensions.add( new Pair<String, List<?>>( name, values ) ); }
private Pair<XSElementDeclaration, Boolean> getTargetElement( Pair<XSElementDeclaration, Boolean> context, QName elName, int num ) { XSTypeDefinition typeDef = context.getFirst().getTypeDefinition(); if ( !( typeDef instanceof XSComplexTypeDefinition ) ) { throw new IllegalArgumentException( "XPath refers to a simple type definition." ); } XSParticle particle = ( (XSComplexTypeDefinition) typeDef ).getParticle(); if ( particle == null ) { throw new IllegalArgumentException( "XPath refers to an empty type definition." ); } return getTargetElementTerm( new Pair<XSTerm, Boolean>( particle.getTerm(), null ), elName, num ); }
private String retrieveTypeOfPrimaryKey( TableName fromTable, SQLIdentifier toColumn, FIDMapping fidMapping ) { if ( fidMapping != null ) { for ( Pair<SQLIdentifier, BaseType> column : fidMapping.getColumns() ) { if ( toColumn.equals( column.getFirst() ) ) { return getDBType( column.getSecond() ); } } } // in joins not connected to the main feature type table 'integer' is used by default if ( !fromTable.equals( currentFtTable ) ) { return "integer"; } return "varchar(2000)"; }
private void exportKeywords200( DatasetMetadata ftMd ) throws XMLStreamException { if ( ftMd != null ) { List<Pair<List<LanguageString>, CodeType>> keywords = ftMd.getKeywords(); if ( keywords != null && !keywords.isEmpty() ) { writer.writeStartElement( OWS110_NS, "Keywords" ); for ( Pair<List<LanguageString>, CodeType> keywordsPerCodeType : keywords ) { for ( LanguageString keyword : keywordsPerCodeType.getFirst() ) { writer.writeStartElement( OWS110_NS, "Keyword" ); writer.writeCharacters( keyword.getString() ); writer.writeEndElement(); } } writer.writeEndElement(); } } }
private String buildNewFid() throws FeatureStoreException { if ( get( fidMapping.getColumns().get( 0 ).getFirst() ) == null ) { // fid columns not available yet return null; } String newId = fidMapping.getPrefix(); List<Pair<SQLIdentifier, BaseType>> fidColumns = fidMapping.getColumns(); newId += checkFIDParticle( fidColumns.get( 0 ).first ); for ( int i = 1; i < fidColumns.size(); i++ ) { newId += fidMapping.getDelimiter() + checkFIDParticle( fidColumns.get( i ).first ); } return newId; }
private static final void maybeAddPair( int num, Geometry g, boolean withGeometry, boolean exact, List<Pair<Integer, Geometry>> list, Envelope bbox ) { if ( exact ) { if ( bbox.intersects( g ) ) { list.add( new Pair<Integer, Geometry>( num, withGeometry ? g : null ) ); } } else { list.add( new Pair<Integer, Geometry>( num, g ) ); } }
private String retrieveTypeOfPrimaryKey( TableName fromTable, SQLIdentifier toColumn, FIDMapping fidMapping ) { if ( fidMapping != null ) { for ( Pair<SQLIdentifier, BaseType> column : fidMapping.getColumns() ) { if ( toColumn.equals( column.getFirst() ) ) { return getDBType( column.getSecond() ); } } } // TODO implement this correctly // in joins not connected to the main feature type table 'integer' is used by default if ( !fromTable.equals( currentFtTable ) ) { return "integer"; } return "text"; }
private Mapping buildMapping( TableName currentTable, Pair<XSElementDeclaration, Boolean> elDecl, PrimitiveParticleJAXB config ) { ValueReference path = new ValueReference( config.getPath(), nsBindings ); Pair<PrimitiveType, Boolean> pt = null; try { pt = schemaWalker.getTargetType( elDecl, path ); } catch ( RuntimeException e ) { throw new RuntimeException( "Error in mapping of table '" + currentTable + "': " + e ); } if ( config.getType() != null ) { PrimitiveType forcedType = new PrimitiveType( getPrimitiveType( config.getType() ) ); LOG.debug( "Overriding schema-derived primitive type '" + pt.getFirst() + "'. Forcing '" + forcedType + "'." ); pt.first = forcedType; } MappingExpression me = parseMappingExpression( config.getMapping() ); List<TableJoin> joinedTable = buildJoinTable( currentTable, config.getJoin() ); LOG.debug( "Targeted primitive type: " + pt ); boolean escalateVoid = determineParticleVoidability( pt.second, config.getNullEscalation() ); return new PrimitiveMapping( path, escalateVoid, me, pt.first, joinedTable, config.getCustomConverter() ); }
private List<Pair<Long, Long>> createBatches( List<Long> positions, long dataSize ) { long step = 25 * 1048576; // mb long begin = 0; long end = 0; long nextStep = step; List<Pair<Long, Long>> result = new java.util.LinkedList<Pair<Long, Long>>(); for ( Long position : positions ) { end = position; if ( end > nextStep ) { result.add( new Pair<Long, Long>( begin, end ) ); begin = end; nextStep += step; } if ( end > dataSize ) { LOG.warn( "The data position: " + end + " is larger than the size of the datafile: " + dataSize + " this is strange." ); } } result.add( new Pair<Long, Long>( begin, dataSize ) ); return result; }
private String retrieveTypeOfPrimaryKey( TableName fromTable, SQLIdentifier toColumn, FIDMapping fidMapping ) { if ( fidMapping != null ) { for ( Pair<SQLIdentifier, BaseType> column : fidMapping.getColumns() ) { if ( toColumn.equals( column.getFirst() ) ) { return getDBType( column.getSecond() ); } } } // TODO implement this correctly // in joins not connected to the main feature type table 'integer' is used by default if ( !fromTable.equals( currentFtTable ) ) { return "integer"; } return "varchar(2000)"; }
PrimitiveParticleConverter primitiveConverter = mgr.getDialect().getPrimitiveConverter( idColumn.first.getName(), type ); addPreparedArgument( idColumn.getFirst(), primitiveValue, primitiveConverter );
private static void addBooleanProp( String propNs, String propName, DatabaseTables table, String column ) { QName qName = new QName( propNs, propName ); Triple<Pair<String, String>, Boolean, BaseType> mapping = new Triple<Pair<String, String>, Boolean, BaseType>( new Pair<String, String>( table.name(), column ), false, BOOLEAN ); propToTableAndCol.put( qName, mapping ); }
private GeometryMapping buildMapping( TableName currentTable, Pair<XSElementDeclaration, Boolean> elDecl, GeometryParticleJAXB config ) { ValueReference path = new ValueReference( config.getPath(), nsBindings ); MappingExpression me = parseMappingExpression( config.getMapping() ); elDecl = schemaWalker.getTargetElement( elDecl, path ); QName ptName = new QName( elDecl.first.getNamespace(), elDecl.getFirst().getName() ); ObjectPropertyType pt = gmlSchema.getGMLSchema().getGMLPropertyDecl( elDecl.first, ptName, 1, 1, null ); GeometryType type = GeometryType.GEOMETRY; if ( pt instanceof GeometryPropertyType ) { type = ( (GeometryPropertyType) pt ).getGeometryType(); } boolean escalateVoid = determineParticleVoidability( elDecl.second, config.getNullEscalation() ); List<TableJoin> joinedTable = buildJoinTable( currentTable, config.getJoin() ); return new GeometryMapping( path, escalateVoid, me, type, geometryParams, joinedTable, config.getCustomConverter() ); }
private static void addGeometryProp( String propNs, String propName, DatabaseTables table, String column, boolean concatenated ) { QName qName = new QName( propNs, propName ); Triple<Pair<String, String>, Boolean, BaseType> mapping = new Triple<Pair<String, String>, Boolean, BaseType>( new Pair<String, String>( table.name(), column ), concatenated, null ); propToTableAndCol.put( qName, mapping ); }
private static void addDateProp( String propNs, String propName, DatabaseTables table, String column ) { QName qName = new QName( propNs, propName ); Triple<Pair<String, String>, Boolean, BaseType> mapping = new Triple<Pair<String, String>, Boolean, BaseType>( new Pair<String, String>( table.name(), column ), false, DATE_TIME ); propToTableAndCol.put( qName, mapping ); }
private static void addIntProp( String propNs, String propName, DatabaseTables table, String column ) { QName qName = new QName( propNs, propName ); Triple<Pair<String, String>, Boolean, BaseType> mapping = new Triple<Pair<String, String>, Boolean, BaseType>( new Pair<String, String>( table.name(), column ), false, INTEGER ); propToTableAndCol.put( qName, mapping ); }
private static void addDecimalProp( String propNs, String propName, DatabaseTables table, String column ) { QName qName = new QName( propNs, propName ); Triple<Pair<String, String>, Boolean, BaseType> mapping = new Triple<Pair<String, String>, Boolean, BaseType>( new Pair<String, String>( table.name(), column ), false, DECIMAL ); propToTableAndCol.put( qName, mapping ); }
/** * Creates a new {@link DCP} instance. * * @param getUrl * endpoint for HTTP-GET requests, can be <code>null</code> * @param postUrl * endpoint for HTTP-POST requests, can be <code>null</code> */ public DCP( URL getUrl, URL postUrl ) { getEndpoints = new ArrayList<Pair<URL, List<Domain>>>(); if ( getUrl != null ) { getEndpoints.add( new Pair<URL, List<Domain>>( getUrl, new ArrayList<Domain>() ) ); } postEndpoints = new ArrayList<Pair<URL, List<Domain>>>(); if ( postUrl != null ) { postEndpoints.add( new Pair<URL, List<Domain>>( postUrl, new ArrayList<Domain>() ) ); } }
/** * @param <T> * @param <U> * @param map * @return two separate lists */ public static <T, U> Pair<ArrayList<T>, ArrayList<U>> unzip( Map<T, U> map ) { ArrayList<T> list1 = new ArrayList<T>( map.size() ); ArrayList<U> list2 = new ArrayList<U>( map.size() ); for ( Entry<T, U> e : map.entrySet() ) { list1.add( e.getKey() ); list2.add( e.getValue() ); } return new Pair<ArrayList<T>, ArrayList<U>>( list1, list2 ); }