Skip to content

Commit

Permalink
Начало разработки версии 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zhichkin committed Mar 17, 2021
1 parent 8c507c0 commit ea4bdb1
Show file tree
Hide file tree
Showing 38 changed files with 548 additions and 423 deletions.
12 changes: 6 additions & 6 deletions src/dajet-metadata-console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static int Main(string[] args)
new Option<string>("--d", "Database name"),
new Option<string>("--u", "User name (Windows authentication is used if not defined)"),
new Option<string>("--p", "User password if SQL Server authentication is used"),
new Option<string>("--m", "MetaObject name (example: \"Справочник.Номенклатура\")"),
new Option<string>("--m", "MetadataObject name (example: \"Справочник.Номенклатура\")"),
new Option<FileInfo>("--out-file", "File path to save metaobject information"),
new Option<FileInfo>("--out-root", "File path to save configuration information")
};
Expand Down Expand Up @@ -81,7 +81,7 @@ private static void ExecuteCommand(string ms, string pg, string d, string u, str

if (outFile != null && !string.IsNullOrWhiteSpace(m))
{
SaveMetaObjectToFile(outFile.FullName, fileReader, m);
SaveMetadataObjectToFile(outFile.FullName, fileReader, m);
}
}
private static void SaveConfigToFile(string filePath, IMetadataFileReader fileReader, IConfigurationFileParser configParser)
Expand All @@ -94,15 +94,15 @@ private static void SaveConfigToFile(string filePath, IMetadataFileReader fileRe
writer.Write(reader.ReadToEnd());
}
}
private static void SaveMetaObjectToFile(string filePath, IMetadataFileReader fileReader, string metadataName)
private static void SaveMetadataObjectToFile(string filePath, IMetadataFileReader fileReader, string metadataName)
{
string[] names = metadataName.Split('.');
if (names.Length != 2) return;
string typeName = names[0];
string objectName = names[1];

MetaObject metaObject = null;
Dictionary<Guid, MetaObject> collection = null;
MetadataObject metaObject = null;
Dictionary<Guid, MetadataObject> collection = null;
IMetadataReader metadata = new MetadataReader(fileReader);
InfoBase infoBase = metadata.LoadInfoBase();
if (typeName == "Справочник") collection = infoBase.Catalogs;
Expand All @@ -115,7 +115,7 @@ private static void SaveMetaObjectToFile(string filePath, IMetadataFileReader fi
metaObject = collection.Values.Where(o => o.Name == objectName).FirstOrDefault();
if (metaObject == null) return;

byte[] fileData = fileReader.ReadBytes(metaObject.UUID.ToString());
byte[] fileData = fileReader.ReadBytes(metaObject.FileName.ToString());
if (fileData == null) return;

using (StreamReader reader = fileReader.CreateReader(fileData))
Expand Down
4 changes: 2 additions & 2 deletions src/dajet-metadata-tests/CatalogHierarchyOfElements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace DaJet.Metadata.Tests
{
[TestClass] public class CatalogHierarchyOfElements : TestClassBase
{
private MetaObject Catalog { get; set; }
private MetadataObject Catalog { get; set; }
public CatalogHierarchyOfElements() : base() { }
private void SetupMetaObject()
private void SetupMetadataObject()
{
if (Catalog != null) return;
SetupInfoBase();
Expand Down
4 changes: 2 additions & 2 deletions src/dajet-metadata-tests/CatalogHierarchyOfFolders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace DaJet.Metadata.Tests
{
[TestClass] public class CatalogHierarchyOfFolders : TestClassBase
{
private MetaObject Catalog { get; set; }
private MetadataObject Catalog { get; set; }
public CatalogHierarchyOfFolders() : base() { }
private void SetupMetaObject()
private void SetupMetadataObject()
{
if (Catalog != null) return;
SetupInfoBase();
Expand Down
10 changes: 5 additions & 5 deletions src/dajet-metadata-tests/CatalogWithMultipleOwners.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace DaJet.Metadata.Tests
{
[TestClass] public class CatalogWithMutlipleOwners : TestClassBase
{
private MetaObject Catalog { get; set; }
private MetadataObject Catalog { get; set; }
public CatalogWithMutlipleOwners() : base() { }
private void SetupMetaObject()
private void SetupMetadataObject()
{
if (Catalog != null) return;
SetupInfoBase();
Expand All @@ -18,8 +18,8 @@ private void SetupMetaObject()
}
[TestMethod("Владелец")] public void TestPropertyВладелец()
{
SetupMetaObject();
MetaProperty property = TestPropertyExists(Catalog, "Владелец");
SetupMetadataObject();
MetadataProperty property = TestPropertyExists(Catalog, "Владелец");

Assert.AreEqual(property.Purpose, PropertyPurpose.System);
Assert.IsFalse(property.PropertyType.IsUuid);
Expand All @@ -32,7 +32,7 @@ private void SetupMetaObject()
Assert.IsTrue(property.PropertyType.CanBeReference);
Assert.IsTrue(property.PropertyType.IsMultipleType);
Assert.AreEqual(property.PropertyType.ReferenceTypeCode, 0);
MetaField field;
DatabaseField field;
field = TestFieldExists(property, "_OwnerID_TYPE");
Assert.AreEqual(field.Length, 1);
Assert.AreEqual(field.TypeName, "binary");
Expand Down
10 changes: 5 additions & 5 deletions src/dajet-metadata-tests/CatalogWithOwner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace DaJet.Metadata.Tests
{
[TestClass] public class CatalogWithOwner : TestClassBase
{
private MetaObject Catalog { get; set; }
private MetadataObject Catalog { get; set; }
public CatalogWithOwner() : base() { }
private void SetupMetaObject()
private void SetupMetadataObject()
{
if (Catalog != null) return;
SetupInfoBase();
Expand All @@ -18,8 +18,8 @@ private void SetupMetaObject()
}
[TestMethod("Владелец")] public void TestPropertyВладелец()
{
SetupMetaObject();
MetaProperty property = TestPropertyExists(Catalog, "Владелец");
SetupMetadataObject();
MetadataProperty property = TestPropertyExists(Catalog, "Владелец");

Assert.AreEqual(property.Purpose, PropertyPurpose.System);
Assert.IsFalse(property.PropertyType.IsUuid);
Expand All @@ -32,7 +32,7 @@ private void SetupMetaObject()
Assert.IsTrue(property.PropertyType.CanBeReference);
Assert.IsFalse(property.PropertyType.IsMultipleType);
Assert.AreNotEqual(property.PropertyType.ReferenceTypeCode, 0);
MetaField field = TestFieldExists(property, "_OwnerIDRRef");
DatabaseField field = TestFieldExists(property, "_OwnerIDRRef");
Assert.AreEqual(field.Length, 16);
Assert.AreEqual(field.TypeName, "binary");
}
Expand Down
14 changes: 7 additions & 7 deletions src/dajet-metadata-tests/PostgresTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public PostgresTests()
string typeName = names[0];
string objectName = names[1];

MetaObject metaObject = null;
Dictionary<Guid, MetaObject> collection = null;
MetadataObject metaObject = null;
Dictionary<Guid, MetadataObject> collection = null;
InfoBase infoBase = metadata.LoadInfoBase();
if (typeName == "Справочник") collection = infoBase.Catalogs;
else if (typeName == "Документ") collection = infoBase.Documents;
Expand Down Expand Up @@ -131,22 +131,22 @@ private void ShowList(string name, List<string> list)
Console.WriteLine(" - " + item);
}
}
private void ShowProperties(MetaObject metaObject)
private void ShowProperties(MetadataObject metaObject)
{
Console.WriteLine(metaObject.Name + " (" + metaObject.TableName + "):");
foreach (MetaProperty property in metaObject.Properties)
foreach (MetadataProperty property in metaObject.Properties)
{
Console.WriteLine(" - " + property.Name + " (" + property.Field + ")");
}
}
private MetaObject GetMetaObjectByName(string metadataName)
private MetadataObject GetMetadataObjectByName(string metadataName)
{
string[] names = metadataName.Split('.');
if (names.Length != 2) return null;
string typeName = names[0];
string objectName = names[1];

Dictionary<Guid, MetaObject> collection = null;
Dictionary<Guid, MetadataObject> collection = null;
InfoBase infoBase = metadata.LoadInfoBase();
if (typeName == "Справочник") collection = infoBase.Catalogs;
else if (typeName == "Документ") collection = infoBase.Documents;
Expand All @@ -159,7 +159,7 @@ private MetaObject GetMetaObjectByName(string metadataName)
[TestMethod("Добавление свойств по метаданным СУБД")] public void MergeProperties()
{
string[] metadataName = { "Справочник.ВходящаяОчередьRabbitMQ", "Справочник.ИсходящаяОчередьRabbitMQ" };
MetaObject metaObject = GetMetaObjectByName(metadataName[0]);
MetadataObject metaObject = GetMetadataObjectByName(metadataName[0]);
if (metaObject == null)
{
Console.WriteLine($"Metaobject \"{metadataName[0]}\" is not found.");
Expand Down
52 changes: 26 additions & 26 deletions src/dajet-metadata-tests/PublicationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public sealed class PublicationTests : TestClassBase
private readonly IConfigurationFileParser configReader;

private readonly bool MSSQL = true;
private MetaObject Publication { get; set; }
private MetadataObject Publication { get; set; }
public PublicationTests() : base()
{
if (MSSQL)
Expand Down Expand Up @@ -47,7 +47,7 @@ protected override void SetupInfoBase()
InfoBase = metadata.LoadInfoBase();
Assert.IsNotNull(InfoBase);
}
private void SetupMetaObject()
private void SetupMetadataObject()
{
if (Publication != null) return;
SetupInfoBase();
Expand All @@ -58,14 +58,14 @@ private void SetupMetaObject()
}
[TestMethod("Свойства плана обмена")] public void TestPublicationProperties()
{
SetupMetaObject();
SetupMetadataObject();

string alias = MSSQL ? "План обмена" : "Тестовый";
string table = string.Format(MSSQL ? "_Node{0}" : "_node{0}", Publication.TypeCode);

Assert.IsTrue(Publication.IsReferenceType);
Assert.AreEqual(Publication.Alias, alias);
Assert.AreEqual(Publication.TypeName, MetaObjectTypes.Publication);
Assert.AreEqual(Publication.TypeName, MetadataObjectTypes.Publication);
Assert.AreEqual(Publication.TableName.ToLowerInvariant(), table.ToLowerInvariant());

Console.WriteLine("Name: " + Publication.Name);
Expand Down Expand Up @@ -94,8 +94,8 @@ private void SetupMetaObject()
}
[TestMethod("Ссылка")] public void TestPropertyСсылка()
{
SetupMetaObject();
MetaProperty property = TestPropertyExists(Publication, "Ссылка");
SetupMetadataObject();
MetadataProperty property = TestPropertyExists(Publication, "Ссылка");

Assert.AreEqual(property.Purpose, PropertyPurpose.System);
Assert.IsTrue(property.PropertyType.IsUuid);
Expand All @@ -109,16 +109,16 @@ private void SetupMetaObject()
Assert.IsFalse(property.PropertyType.CanBeReference);
Assert.AreEqual(property.PropertyType.ReferenceTypeCode, 0);

MetaField field = TestFieldExists(property, "_IDRRef");
DatabaseField field = TestFieldExists(property, "_IDRRef");
Assert.AreEqual(field.Length, 16);
Assert.AreEqual(field.TypeName, "binary");
Assert.AreEqual(field.KeyOrdinal, 1);
Assert.AreEqual(field.IsPrimaryKey, true);
}
[TestMethod("ВерсияДанных")] public void TestPropertyВерсияДанных()
{
SetupMetaObject();
MetaProperty property = TestPropertyExists(Publication, "ВерсияДанных");
SetupMetadataObject();
MetadataProperty property = TestPropertyExists(Publication, "ВерсияДанных");

Assert.AreEqual(property.Purpose, PropertyPurpose.System);
Assert.IsFalse(property.PropertyType.IsUuid);
Expand All @@ -132,14 +132,14 @@ private void SetupMetaObject()
Assert.IsFalse(property.PropertyType.CanBeReference);
Assert.AreEqual(property.PropertyType.ReferenceTypeCode, 0);

MetaField field = TestFieldExists(property, "_Version");
DatabaseField field = TestFieldExists(property, "_Version");
Assert.AreEqual(field.Length, 8);
Assert.AreEqual(field.TypeName, "timestamp");
}
[TestMethod("ПометкаУдаления")] public void TestPropertyПометкаУдаления()
{
SetupMetaObject();
MetaProperty property = TestPropertyExists(Publication, "ПометкаУдаления");
SetupMetadataObject();
MetadataProperty property = TestPropertyExists(Publication, "ПометкаУдаления");

Assert.AreEqual(property.Purpose, PropertyPurpose.System);
Assert.IsFalse(property.PropertyType.IsUuid);
Expand All @@ -153,14 +153,14 @@ private void SetupMetaObject()
Assert.IsFalse(property.PropertyType.CanBeReference);
Assert.AreEqual(property.PropertyType.ReferenceTypeCode, 0);

MetaField field = TestFieldExists(property, "_Marked");
DatabaseField field = TestFieldExists(property, "_Marked");
Assert.AreEqual(field.Length, 1);
Assert.AreEqual(field.TypeName, "binary");
}
[TestMethod("Предопределённый")] public void TestPropertyПредопределённый()
{
SetupMetaObject();
MetaProperty property = TestPropertyExists(Publication, "Предопределённый");
SetupMetadataObject();
MetadataProperty property = TestPropertyExists(Publication, "Предопределённый");

Assert.AreEqual(property.Purpose, PropertyPurpose.System);
Assert.IsTrue(property.PropertyType.IsUuid);
Expand All @@ -174,14 +174,14 @@ private void SetupMetaObject()
Assert.IsFalse(property.PropertyType.CanBeReference);
Assert.AreEqual(property.PropertyType.ReferenceTypeCode, 0);

MetaField field = TestFieldExists(property, "_PredefinedID");
DatabaseField field = TestFieldExists(property, "_PredefinedID");
Assert.AreEqual(field.Length, 16);
Assert.AreEqual(field.TypeName, "binary");
}
[TestMethod("НомерПринятого")] public void TestPropertyНомерПринятого()
{
SetupMetaObject();
MetaProperty property = TestPropertyExists(Publication, "НомерПринятого");
SetupMetadataObject();
MetadataProperty property = TestPropertyExists(Publication, "НомерПринятого");

Assert.AreEqual(property.Purpose, PropertyPurpose.System);
Assert.IsFalse(property.PropertyType.IsUuid);
Expand All @@ -195,16 +195,16 @@ private void SetupMetaObject()
Assert.IsFalse(property.PropertyType.CanBeReference);
Assert.AreEqual(property.PropertyType.ReferenceTypeCode, 0);

MetaField field = TestFieldExists(property, "_ReceivedNo");
DatabaseField field = TestFieldExists(property, "_ReceivedNo");
Assert.AreEqual(field.Length, 9);
Assert.AreEqual(field.Scale, 0);
Assert.AreEqual(field.Precision, 10);
Assert.AreEqual(field.TypeName, "numeric");
}
[TestMethod("НомерОтправленного")] public void TestPropertyНомерОтправленного()
{
SetupMetaObject();
MetaProperty property = TestPropertyExists(Publication, "НомерОтправленного");
SetupMetadataObject();
MetadataProperty property = TestPropertyExists(Publication, "НомерОтправленного");

Assert.AreEqual(property.Purpose, PropertyPurpose.System);
Assert.IsFalse(property.PropertyType.IsUuid);
Expand All @@ -218,7 +218,7 @@ private void SetupMetaObject()
Assert.IsFalse(property.PropertyType.CanBeReference);
Assert.AreEqual(property.PropertyType.ReferenceTypeCode, 0);

MetaField field = TestFieldExists(property, "_SentNo");
DatabaseField field = TestFieldExists(property, "_SentNo");
Assert.AreEqual(field.Length, 9);
Assert.AreEqual(field.Scale, 0);
Assert.AreEqual(field.Precision, 10);
Expand All @@ -233,17 +233,17 @@ private void ShowList(string name, List<string> list)
Console.WriteLine(" - " + item);
}
}
private void ShowProperties(MetaObject metaObject)
private void ShowProperties(MetadataObject metaObject)
{
Console.WriteLine(metaObject.Name + " (" + metaObject.TableName + "):");
foreach (MetaProperty property in metaObject.Properties)
foreach (MetadataProperty property in metaObject.Properties)
{
Console.WriteLine(" - " + property.Name + " (" + property.Field + ")");
}
}
[TestMethod("Добавление свойств по метаданным СУБД")] public void MergeProperties()
{
SetupMetaObject();
SetupMetadataObject();

ShowProperties(Publication);
Console.WriteLine();
Expand Down Expand Up @@ -294,7 +294,7 @@ private void ShowProperties(MetaObject metaObject)

[TestMethod("Загрузка узлов плана обмена")] public void SelectSubscribers()
{
SetupMetaObject();
SetupMetadataObject();

Publication publication = (Publication)Publication;

Expand Down
Loading

0 comments on commit ea4bdb1

Please sign in to comment.