diff --git a/src/Dynamicweb.DataIntegration.Providers.ODataProvider.csproj b/src/Dynamicweb.DataIntegration.Providers.ODataProvider.csproj
index d5945fb..c57c0a2 100644
--- a/src/Dynamicweb.DataIntegration.Providers.ODataProvider.csproj
+++ b/src/Dynamicweb.DataIntegration.Providers.ODataProvider.csproj
@@ -24,7 +24,7 @@
snupkg
-
+
diff --git a/src/ODataProvider.cs b/src/ODataProvider.cs
index 6b9acb0..3fe05f3 100644
--- a/src/ODataProvider.cs
+++ b/src/ODataProvider.cs
@@ -1,14 +1,5 @@
-using Dynamicweb.Core;
-using Dynamicweb.DataIntegration.EndpointManagement;
-using Dynamicweb.DataIntegration.Integration;
-using Dynamicweb.DataIntegration.Integration.ERPIntegration;
-using Dynamicweb.DataIntegration.Integration.Interfaces;
-using Dynamicweb.DataIntegration.Providers.ODataProvider.Interfaces;
+using Dynamicweb.DataIntegration.Providers.ODataProvider.Interfaces;
using Dynamicweb.DataIntegration.Providers.ODataProvider.Model;
-using Dynamicweb.Extensibility.AddIns;
-using Dynamicweb.Extensibility.Editors;
-using Dynamicweb.Logging;
-using Dynamicweb.Security.Licensing;
using System;
using System.Collections.Generic;
using System.IO;
@@ -321,7 +312,7 @@ private void GetColumnsFromEntityTypeTableToEntitySetTable(Table table, Schema e
{
if (table.Columns.Where(obj => obj.Name == item.Name).Count() == 0)
{
- table.AddColumn(new Column(item.Name, item.Type, table, item.IsPrimaryKey, item.IsNew));
+ table.AddColumn(new Column(item.Name, item.Type, table, item.IsPrimaryKey, item.IsNew, item.ReadOnly));
}
}
}
@@ -332,6 +323,7 @@ private void AddPropertiesFromXMLReaderToTable(XmlReader xmlReader, Table table,
string baseType = xmlReader.GetAttribute("BaseType");
string entityName = xmlReader.GetAttribute("Name");
List primaryKeys = new List();
+ Column column = null;
while (xmlReader.Read() && !(xmlReader.NodeType == XmlNodeType.EndElement && xmlReader.Name.Equals("EntityType", StringComparison.OrdinalIgnoreCase)))
{
if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name.Equals("PropertyRef", StringComparison.OrdinalIgnoreCase))
@@ -344,7 +336,27 @@ private void AddPropertiesFromXMLReaderToTable(XmlReader xmlReader, Table table,
var columnTypeString = xmlReader.GetAttribute("Type");
var columnType = GetColumnType(columnTypeString);
var isPrimaryKey = primaryKeys.Contains(columnName);
- table.AddColumn(new Column(columnName, columnType, table, isPrimaryKey, false));
+ column = new Column(columnName, columnType, table, isPrimaryKey, false);
+ table.AddColumn(column);
+ // BC
+ var scale = xmlReader.GetAttribute("Scale");
+ if (scale is not null && string.Equals(scale, "Variable", StringComparison.OrdinalIgnoreCase))
+ column.ReadOnly = true;
+ }
+ else if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name.Equals("Annotation", StringComparison.OrdinalIgnoreCase) && column is not null)
+ {
+ // BC & FO
+ var term = xmlReader.GetAttribute("Term");
+ var value = xmlReader.GetAttribute("Bool");
+ if (!string.IsNullOrEmpty(term) && term.Contains("AllowEdit") && !string.IsNullOrEmpty(value) && !Converter.ToBoolean(value))
+ column.ReadOnly = true;
+ }
+ else if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name.Equals("EnumMember", StringComparison.OrdinalIgnoreCase) && column is not null)
+ {
+ // CRM
+ string permission = xmlReader.Value;
+ if (!string.IsNullOrEmpty(permission) && permission.ToLower().EndsWith("permissiontype/read"))
+ column.ReadOnly = true;
}
else if (xmlReader.Name.Equals("EntityType", StringComparison.OrdinalIgnoreCase) && xmlReader.GetAttribute("Name") != entityName)
{
@@ -361,7 +373,7 @@ private void AddPropertiesFromXMLReaderToTable(XmlReader xmlReader, Table table,
{
if (table.Columns.Where(obj => obj.Name == item.Name).Count() == 0)
{
- table.AddColumn(new Column(item.Name, item.Type, table, item.IsPrimaryKey, item.IsNew));
+ table.AddColumn(new Column(item.Name, item.Type, table, item.IsPrimaryKey, item.IsNew, item.ReadOnly));
}
}
}
diff --git a/src/ODataWriter.cs b/src/ODataWriter.cs
index bbd65a9..ae32eb4 100644
--- a/src/ODataWriter.cs
+++ b/src/ODataWriter.cs
@@ -251,7 +251,7 @@ internal string MapValuesToJSon(ColumnMappingCollection columnMappings, Dictiona
foreach (ColumnMapping columnMapping in columnMappings)
{
- if (!columnMapping.Active || (columnMapping.ScriptValueForInsert && isPatchRequest))
+ if (!columnMapping.Active || (columnMapping.ScriptValueForInsert && isPatchRequest) || (columnMapping.DestinationColumn is not null && !columnMapping.DestinationColumn.ReadOnly))
continue;
if (columnMapping.HasScriptWithValue || row.ContainsKey(columnMapping.SourceColumn?.Name))