// remove existing updload field mappings
GisUploadField.delete("gisUpload = ?", gisUpload);
FileDataStore store = FileDataStoreFinder.getDataStore(shapeFile);
SimpleFeatureSource featureSource = store.getFeatureSource();
SimpleFeatureCollection featureCollection = featureSource.getFeatures();
SimpleFeatureIterator featureIterator = featureCollection.features();
List<AttributeDescriptor> attributeDescriptors = featureSource.getSchema().getAttributeDescriptors();
// update field listing
Long position = new Long(0);
for(AttributeDescriptor attribute : attributeDescriptors)
{
GisUploadField field = new GisUploadField();
field.fieldName = attribute.getName().toString();
field.fieldType = attribute.getType().getName().getLocalPart();
field.fieldPosition = position;
field.gisUpload = gisUpload;
field.save();
position++;
}
CoordinateReferenceSystem dataCRS = featureSource.getSchema().getCoordinateReferenceSystem();
String code = "EPSG:4326";
CRSAuthorityFactory crsAuthorityFactory = CRS.getAuthorityFactory(true);
CoordinateReferenceSystem mapCRS = crsAuthorityFactory.createCoordinateReferenceSystem(code);