String month,
String day,
boolean forceCreation)
throws PostGisException {
DataStore dstDs=null;
SimpleFeatureSource fsLayer = null;
Transaction tx = new DefaultTransaction();
//== check schema: create new or check they are aligned
try {
// craete destination store
dstDs = createDatastore(dstPg);
// check if destinationlayer exists
boolean layerExists = existFeatureTable(dstDs, layer);
if( ! layerExists ) {
if(forceCreation) {
fsLayer = createEnrichedSchema(dstDs, (SimpleFeatureType) sourceFC.getSchema(), layer);
} else {
throw new PostGisException("The layer " + layer + " does not exist");
}
} else {
fsLayer = dstDs.getFeatureSource(layer);
checkAttributesMatch(sourceFC, ((JDBCFeatureStore)dstDs.getFeatureSource(layer)).getFeatureSource());
}
//== schemas are ok: transfer data
int iYear = Integer.parseInt(year);
int iMonth = month==null? -1 : Integer.parseInt(month);
int iDay = day==null? -1 : Integer.parseInt(day);
Date date = new Date(iYear-1900, iMonth==-1?0:iMonth-1, iDay==-1?1:iDay);
SimpleFeatureStore featureStoreData = (SimpleFeatureStore) fsLayer;
// update the layer store with the new SimpleFeature coming from the shape file
// data are saved itemsForPage elements at time
SimpleFeatureType dstSchema = dstDs.getSchema(layer);
featureStoreData.setTransaction(tx);
SimpleFeatureType srcSchema = sourceFC.getSchema();
List<AttributeDescriptor> srcAttributeDescriptor = srcSchema.getAttributeDescriptors();
SimpleFeatureBuilder featureBuilderData = new SimpleFeatureBuilder(dstSchema);