[mapguide-users] can't update and delete from feature source but
insert works
mitcha
michael_hebig at web.de
Mon Aug 20 07:11:03 EDT 2007
hello everybody,
i need help!!! i try tu update and delete a feature source (sdf file), but
it doesn't work! instead inserting new data into feature source work very
well! i searched for solutions in this forum and i found some similar
problems.
So I first tried to set the readonly flag of the schema to false with the
mapagent. now the xml presentation looks like this:
<FeatureSource xsi:noNamespaceSchemaLocation="FeatureSource-1.0.0.xsd">
<Provider>OSGeo.SDF</Provider>
<Parameter>
<Name>File</Name>
<Value>%MG_DATA_FILE_PATH%userPoints2.sdf</Value>
</Parameter>
<Parameter>
<Name>ReadOnly</Name>
<Value>FALSE</Value>
</Parameter>
</FeatureSource>
But it doesn't work!!!
furthermore i tried to set the identity property to readonly="false" with
the help of Fdo2Fdo. But it doesn't work, too. i always get an error
message. Could this be my fault? can i change this value of the identity
property?
The last possible reason could be an error im my source code. so here it is:
// --------------------------------------------------//
// Basic initialization needs to be done every time.
MgInitializeWebTier($webconfigFilePath);
// Get the session information passed from the viewer.
$sessionId = ($_SERVER['REQUEST_METHOD'] == "POST")?$_POST['SESSION']:
$_GET['SESSION'];
// Get the user information using the session id,
// and set up a connection to the site server.
$userInfo = new MgUserInformation($sessionId);
$siteConnection = new MgSiteConnection();
$siteConnection->Open($userInfo);
// Get an instance of the required service(s).
$resourceService =
$siteConnection->CreateService(MgServiceType::ResourceService);
$featureService =
$siteConnection->CreateService(MgServiceType::FeatureService);
$queryOptions = new MgFeatureQueryOptions();
//---------------------------------------------------//
// Open the map
$map = new MgMap();
$map->Open($resourceService, $mapName);
// Create the feature source
$featureSourceName =
'Library://einzelBaum/Daten/userPoints2.FeatureSource';
$resourceIdentifier = new MgResourceIdentifier($featureSourceName);
$layerClassName="points2";
//$selectionString=$key;
$selectionString="KEY=1";// just for testing
$queryOptions->SetFilter($selectionString);
$featureReader = $featureService->SelectFeatures($resourceIdentifier,
$layerClassName, $queryOptions);
while ($featureReader->ReadNext())
{
$searchName = $featureReader->GetString('NAME');
echo 'searchName: '.$searchName;
$searchBeschreibung = $featureReader->GetString('Beschreibung');
echo 'beschrName: '.$searchBeschreibung;
}
// We need to add some data to the sdf before using it. The spatial
context
// reader must have an extent.
$propertyCollection = new MgPropertyCollection();
$nameProperty = new MgStringProperty("NAME", $name);
$propertyCollection->Add($nameProperty);
$beschreibungProperty = new MgStringProperty("Beschreibung", $beschreib);
$propertyCollection->Add($beschreibungProperty);
$cmd = new MgUpdateFeatures("points2", $propertyCollection, $queryOptions);
$featureCommandCollection = new MgFeatureCommandCollection();
$featureCommandCollection->Add($cmd);
// Execute the "add" commands
if ($featureCommandCollection->GetCount() >= 1 )
{
echo "commands.GetCount: ".$featureCommandCollection->GetCount();
$featureService->UpdateFeatures($resourceIdentifier,
$featureCommandCollection, false);
}
$featureReader2 = $featureService->SelectFeatures($resourceIdentifier,
$layerClassName, $queryOptions);
while ($featureReader2->ReadNext())
{
$searchName = $featureReader2->GetString('NAME');
echo 'searchNameAfter: '.$searchName;
$searchBeschreibung = $featureReader2->GetString('Beschreibung');
echo 'beschrNameAfter: '.$searchBeschreibung;
}
//---------------------------------------------------//
// Save the map back to the session repository
$sessionIdName = "Session:$sessionId//$mapName.Map";
$sessionResourceID = new MgResourceIdentifier($sessionIdName);
$sessionResourceID->Validate();
$map->Save($resourceService, $sessionResourceID);
//---------------------------------------------------//
i hope that anybody can help!
greetz mitcha
--
View this message in context: http://www.nabble.com/can%27t-update-and-delete-from-feature-source-but-insert-works-tf4298167s16610.html#a12233926
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list