本文整理汇总了C#中IDomainObjectDTORepository.AllInstancesSansSubclasses方法的典型用法代码示例。如果您正苦于以下问题:C# IDomainObjectDTORepository.AllInstancesSansSubclasses方法的具体用法?C# IDomainObjectDTORepository.AllInstancesSansSubclasses怎么用?C# IDomainObjectDTORepository.AllInstancesSansSubclasses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDomainObjectDTORepository
的用法示例。
在下文中一共展示了IDomainObjectDTORepository.AllInstancesSansSubclasses方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Makes LexEntries be unowned.
/// </summary>
/// <param name="domainObjectDtoRepository">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// <remarks>
/// The method must add/remove/update the DTOs to the repository,
/// as it adds/removes objects as part of it work.
///
/// Implementors of this interface should ensure the Repository's
/// starting model version number is correct for the step.
/// Implementors must also increment the Repository's model version number
/// at the end of its migration work.
///
/// The method also should normally modify the xml string(s)
/// of relevant DTOs, since that string will be used by the main
/// data migration calling client (ie. BEP).
/// </remarks>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000027);
var lexDbDto = domainObjectDtoRepository.AllInstancesSansSubclasses("LexDb").First();
var lexDb = XElement.Parse(lexDbDto.Xml);
var entries = lexDb.Element("Entries");
if (entries != null)
{
entries.Remove();
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, lexDbDto, lexDb.ToString());
}
foreach (var entryDto in domainObjectDtoRepository.AllInstancesSansSubclasses("LexEntry"))
{
XElement entry = XElement.Parse(entryDto.Xml);
var ownerAttr = entry.Attribute("ownerguid");
if (ownerAttr != null)
{
ownerAttr.Remove();
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, entryDto, entry.ToString());
}
}
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例2: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Perform one increment migration step.
/// </summary>
/// <param name="domainObjectDtoRepository">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// <remarks>
/// The method must add/remove/update the DTOs to the repository,
/// as it adds/removes objects as part of it work.
///
/// Implementors of this interface should ensure the Repository's
/// starting model version number is correct for the step.
/// Implementors must also increment the Repository's model version number
/// at the end of its migration work.
///
/// The method also should normally modify the xml string(s)
/// of relevant DTOs, since that string will be used by the main
/// data migration calling client (ie. BEP).
/// </remarks>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000000);
DataMigrationServices.Delint(domainObjectDtoRepository);
var lpDto = domainObjectDtoRepository.AllInstancesSansSubclasses("LangProject").First();
// 1. Remove property from LangProg.
var lpElement = XElement.Parse(lpDto.Xml);
lpElement.Descendants("WordformInventory").Remove();
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, lpDto, lpElement.ToString());
// 2. Remove three owner-related attributes from each WfiWordform.
// (There may be zero, or more, instances to upgrade.)
foreach (var wordformDto in domainObjectDtoRepository.AllInstancesSansSubclasses("WfiWordform"))
{
var wfElement = XElement.Parse(wordformDto.Xml);
wfElement.Attribute("ownerguid").Remove();
var flidAttr = wfElement.Attribute("owningflid");
if (flidAttr != null)
flidAttr.Remove();
var ordAttr = wfElement.Attribute("owningord");
if (ordAttr != null)
ordAttr.Remove();
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, wordformDto, wfElement.ToString());
}
// 3. Remove WordformInventory instance.
domainObjectDtoRepository.Remove(
domainObjectDtoRepository.AllInstancesSansSubclasses("WordformInventory").First());
// There are no references to the WFI, so don't fret about leaving dangling refs to it.
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例3: PerformMigration
/// <summary>
/// Updates the Data Notebook RecordTypes possibilities to use specific GUIDs.
/// </summary>
/// <param name="domainObjectDtoRepository">Repository of all CmObject DTOs available for one migration step.</param>
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000010);
DomainObjectDTO nbkDto = domainObjectDtoRepository.AllInstancesSansSubclasses("RnResearchNbk").First();
XElement nbkElem = XElement.Parse(nbkDto.Xml);
var recTypesGuid = (string) nbkElem.XPathSelectElement("RnResearchNbk/RecTypes/objsur").Attribute("guid");
var stack = new Stack<DomainObjectDTO>(domainObjectDtoRepository.GetDirectlyOwnedDTOs(recTypesGuid));
IEnumerable<DomainObjectDTO> recDtos = domainObjectDtoRepository.AllInstancesSansSubclasses("RnGenericRec");
IEnumerable<DomainObjectDTO> overlayDtos = domainObjectDtoRepository.AllInstancesSansSubclasses("CmOverlay");
while (stack.Count > 0)
{
DomainObjectDTO dto = stack.Pop();
foreach (DomainObjectDTO childDto in domainObjectDtoRepository.GetDirectlyOwnedDTOs(dto.Guid))
stack.Push(childDto);
XElement posElem = XElement.Parse(dto.Xml);
XElement uniElem = posElem.XPathSelectElement("CmPossibility/Abbreviation/AUni[@ws='en']");
if (uniElem != null)
{
string newGuid = null;
switch (uniElem.Value)
{
case "Con":
newGuid = "B7B37B86-EA5E-11DE-80E9-0013722F8DEC";
break;
case "Intv":
newGuid = "B7BF673E-EA5E-11DE-9C4D-0013722F8DEC";
break;
case "Str":
newGuid = "B7C8F092-EA5E-11DE-8D7D-0013722F8DEC";
break;
case "Uns":
newGuid = "B7D4DC4A-EA5E-11DE-867C-0013722F8DEC";
break;
case "Lit":
newGuid = "B7E0C7F8-EA5E-11DE-82CC-0013722F8DEC";
break;
case "Obs":
newGuid = "B7EA5156-EA5E-11DE-9F9C-0013722F8DEC";
break;
case "Per":
newGuid = "B7F63D0E-EA5E-11DE-9F02-0013722F8DEC";
break;
case "Ana":
newGuid = "82290763-1633-4998-8317-0EC3F5027FBD";
break;
}
if (newGuid != null)
DataMigrationServices.ChangeGuid(domainObjectDtoRepository, dto, newGuid, recDtos.Concat(overlayDtos));
}
}
DomainObjectDTO recTypesDto = domainObjectDtoRepository.GetDTO(recTypesGuid);
DataMigrationServices.ChangeGuid(domainObjectDtoRepository, recTypesDto, "D9D55B12-EA5E-11DE-95EF-0013722F8DEC", overlayDtos);
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例4: PerformMigration
public void PerformMigration(IDomainObjectDTORepository repoDto)
{
DataMigrationServices.CheckVersionNumber(repoDto, 7000041);
var dtoLexDb = repoDto.AllInstancesSansSubclasses("LexDb").First();
var xeLexDb = XElement.Parse(dtoLexDb.Xml);
var guidComplexTypes = GetGuidValue(xeLexDb, "ComplexEntryTypes/objsur");
var guidVariantTypes = GetGuidValue(xeLexDb, "VariantEntryTypes/objsur");
BuildStandardMaps(guidComplexTypes, guidVariantTypes);
var extraTypes = new List<LexTypeInfo>();
var unprotectedTypes = new List<LexTypeInfo>();
foreach (var dto in repoDto.AllInstancesSansSubclasses("LexEntryType"))
{
var xeType = XElement.Parse(dto.Xml);
// ReSharper disable PossibleNullReferenceException
var guid = xeType.Attribute("guid").Value;
// ReSharper restore PossibleNullReferenceException
string name;
if (m_mapGuidName.TryGetValue(guid, out name))
{
m_mapGuidName.Remove(guid);
m_mapNameGuid.Remove(name);
var xeProt = xeType.XPathSelectElement("IsProtected");
if (xeProt == null)
{
unprotectedTypes.Add(new LexTypeInfo(dto, xeType));
}
else
{
var xaVal = xeProt.Attribute("val");
if (xaVal == null || xaVal.Value.ToLowerInvariant() != "true")
unprotectedTypes.Add(new LexTypeInfo(dto, xeType));
}
}
else
{
extraTypes.Add(new LexTypeInfo(dto, xeType));
}
}
foreach (var info in unprotectedTypes)
{
var xeProt = info.XmlElement.XPathSelectElement("IsProtected");
if (xeProt != null)
xeProt.Remove();
info.XmlElement.Add(new XElement("IsProtected", new XAttribute("val", "true")));
info.DTO.Xml = info.XmlElement.ToString();
repoDto.Update(info.DTO);
}
if (m_mapGuidName.Count > 0)
FixOrAddMissingTypes(repoDto, extraTypes);
FixOwnershipOfSubtypes(repoDto);
DataMigrationServices.IncrementVersionNumber(repoDto);
}
示例5: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Change any bogus non-owning footnote links in the vernacular (but NOT in the BT)
/// to be owning links
/// </summary>
/// <param name="domainObjectDtoRepository">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000034);
foreach (var scrTxtPara in domainObjectDtoRepository.AllInstancesSansSubclasses("ScrTxtPara"))
{
XElement para = XElement.Parse(scrTxtPara.Xml);
XElement contents = para.Element("Contents");
if (contents == null)
continue;
XElement str = contents.Element("Str");
if (str == null)
continue;
foreach (XElement run in str.Elements("Run"))
{
XAttribute linkAttr = run.Attribute("link");
if (linkAttr == null)
continue; // Run doesn't contain an unowned hot-link
XAttribute ownedLinkAttr = new XAttribute("ownlink", linkAttr.Value);
run.Add(ownedLinkAttr);
linkAttr.Remove();
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, scrTxtPara, para.ToString());
}
}
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例6: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Changes all StTxtParas that are owned by Scripture to be ScrTxtParas
/// </summary>
/// <param name="domainObjectDtoRepository">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// <remarks>
/// The method must add/remove/update the DTOs to the repository,
/// as it adds/removes objects as part of it work.
///
/// Implementors of this interface should ensure the Repository's
/// starting model version number is correct for the step.
/// Implementors must also increment the Repository's model version number
/// at the end of its migration work.
///
/// The method also should normally modify the xml string(s)
/// of relevant DTOs, since that string will be used by the main
/// data migration calling client (ie. BEP).
/// </remarks>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000001);
var parasToChangeClasses = new List<DomainObjectDTO>();
foreach (var stTxtPara in domainObjectDtoRepository.AllInstancesSansSubclasses("StTxtPara"))
{
var paraOwner = domainObjectDtoRepository.GetOwningDTO(stTxtPara);
if (paraOwner.Classname != "StText" && paraOwner.Classname != "StFootnote")
{
continue; // Paragraph is not owned by an StText or StFootnote (shouldn't ever happen)
}
var textOwner = domainObjectDtoRepository.GetOwningDTO(paraOwner);
if (textOwner.Classname != "ScrBook" && textOwner.Classname != "ScrSection")
{
continue; // StText is not part of Scripture, don't change.
}
// Its one of the paragraphs that we care about. We just need to change the
// class in the xml to be a ScrTxtPara and change the objectsByClass map.
DataMigrationServices.ChangeToSubClass(stTxtPara, "StTxtPara", "ScrTxtPara");
parasToChangeClasses.Add(stTxtPara);
}
// Udate the repository
var startingStructure = new ClassStructureInfo("StPara", "StTxtPara");
var endingStructure = new ClassStructureInfo("StTxtPara", "ScrTxtPara");
foreach (var changedPara in parasToChangeClasses)
domainObjectDtoRepository.Update(changedPara,
startingStructure,
endingStructure);
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例7: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Changes all StFootnotes to ScrFootnotes
/// </summary>
/// <param name="domainObjectDtoRepository">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// <remarks>
/// The method must add/remove/update the DTOs to the repository,
/// as it adds/removes objects as part of it work.
///
/// Implementors of this interface should ensure the Repository's
/// starting model version number is correct for the step.
/// Implementors must also increment the Repository's model version number
/// at the end of its migration work.
///
/// The method also should normally modify the xml string(s)
/// of relevant DTOs, since that string will be used by the main
/// data migration calling client (ie. BEP).
/// </remarks>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000002);
var footnotesToChangeClasses = new List<DomainObjectDTO>();
foreach (var footnote in domainObjectDtoRepository.AllInstancesSansSubclasses("StFootnote"))
{
XElement footnoteEl = XElement.Parse(footnote.Xml);
footnoteEl.Attribute("class").Value = "ScrFootnote";
// Add the empty ScrFootnote element to the ScrFootnote
footnoteEl.Add(new XElement("ScrFootnote"));
// Update the object XML
footnote.Xml = footnoteEl.ToString();
footnote.Classname = "ScrFootnote";
footnotesToChangeClasses.Add(footnote);
}
// Udate the repository
var startingStructure = new ClassStructureInfo("StText", "StFootnote");
var endingStructure = new ClassStructureInfo("StFootnote", "ScrFootnote");
foreach (var changedPara in footnotesToChangeClasses)
domainObjectDtoRepository.Update(changedPara,
startingStructure,
endingStructure);
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例8: PerformMigration
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000050);
var newGuidValue = Guid.NewGuid().ToString().ToLowerInvariant();
const string className = "LangProject";
var lpDto = domainObjectDtoRepository.AllInstancesSansSubclasses(className).First();
var ownedDtos = domainObjectDtoRepository.GetDirectlyOwnedDTOs(lpDto.Guid).ToList();
var data = lpDto.Xml;
domainObjectDtoRepository.Remove(lpDto); // It is pretty hard to change an immutable Guid identifier in BEP-land, so nuke it, and make a new one.
var lpElement = XElement.Parse(data);
lpElement.Attribute("guid").Value = newGuidValue;
var newLpDto = new DomainObjectDTO(newGuidValue, className, lpElement.ToString());
domainObjectDtoRepository.Add(newLpDto);
// Change ownerguid attr for each owned item to new guid.
foreach (var ownedDto in ownedDtos)
{
var ownedElement = XElement.Parse(ownedDto.Xml);
ownedElement.Attribute("ownerguid").Value = newGuidValue;
ownedDto.Xml = ownedElement.ToString();
domainObjectDtoRepository.Update(ownedDto);
}
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例9: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Looks for CmFile objects included in LangProject. If found, will look for CmFile in
/// correct location and replace reference on CmPicture with that new CmFile.
/// </summary>
/// <param name="repoDto">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// <remarks>
/// Implementors of this interface should ensure the Repository's
/// starting model version number is correct for the step.
/// Implementors must also increment the Repository's model version number
/// at the end of its migration work.
///
/// The method also should normally modify the xml string(s)
/// of relevant DTOs, since that string will be used by the main
/// data migration calling client (ie. BEP).
/// </remarks>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository repoDto)
{
DataMigrationServices.CheckVersionNumber(repoDto, 7000033);
var langProj = repoDto.AllInstancesSansSubclasses("LangProject").First();
var langProjElement = XElement.Parse(langProj.Xml);
var pictures = langProjElement.Element("Pictures");
if (pictures != null && pictures.Elements().Count() > 1)
{
DomainObjectDTO folder = null;
bool foundFiles = false;
foreach (var x in pictures.Elements())
{
var xObj = repoDto.GetDTO(x.Attribute("guid").Value);
if (xObj.Classname == "CmFolder")
{
// empty folders can just be removed
var xObjElement = XElement.Parse(xObj.Xml);
if (xObjElement.Element("Files") == null)
DataMigrationServices.RemoveIncludingOwnedObjects(repoDto, xObj, true);
else if (folder == null)
folder = xObj;
else
MoveFileReferences(repoDto, langProj, xObj, folder);
}
else
foundFiles = true;
}
if (folder != null && foundFiles)
RemoveInvalidFiles(repoDto, langProj, folder);
}
DataMigrationServices.IncrementVersionNumber(repoDto);
}
示例10: PerformMigration
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000062);
var wmbLangProjList = domainObjectDtoRepository.AllInstancesSansSubclasses("LangProject");
var wmbLangProj = wmbLangProjList.First();
var wmbLangProjElt = XElement.Parse(wmbLangProj.Xml);
// get the default vernacular ws - it's the 1st in the list of current ones.
var vernWss = wmbLangProjElt.Element("CurVernWss"); // has to be only one
// a new project migrates before adding writing systems to the cache, so if there are no CurVernWss, bail out
if (vernWss != null)
{
var vernWssUni = vernWss.Element("Uni"); // only one
var vernWsList = vernWssUni.Value.Split(' '); // at least one
var vernDefault = vernWsList[0]; // the default
// Create the new property
var sb = new StringBuilder();
sb.Append("<HomographWs>");
sb.AppendFormat("<Uni>{0}</Uni>", vernDefault);
sb.Append("</HomographWs>");
var hgWsElt = XElement.Parse(sb.ToString());
wmbLangProjElt.Add(hgWsElt);
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, wmbLangProj, wmbLangProjElt.ToString());
}
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例11: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Makes Texts (IText) be unowned.
/// </summary>
/// <param name="domainObjectDtoRepository">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// <remarks>
/// The method must add/remove/update the DTOs to the repository,
/// as it adds/removes objects as part of it work.
///
/// Implementors of this interface should ensure the Repository's
/// starting model version number is correct for the step.
/// Implementors must also increment the Repository's model version number
/// at the end of its migration work.
///
/// The method also should normally modify the xml string(s)
/// of relevant DTOs, since that string will be used by the main
/// data migration calling client (ie. BEP).
/// </remarks>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000058);
// Remove LangProject Texts property
var lpDto = domainObjectDtoRepository.AllInstancesSansSubclasses("LangProject").First();
var lp = XElement.Parse(lpDto.Xml);
var texts = lp.Element("Texts");
if (texts != null)
{
texts.Remove();
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, lpDto, lp.ToString());
}
// Change RnGenericRec Text property from owned to reference
foreach (var rnRecDto in domainObjectDtoRepository.AllInstancesSansSubclasses("RnGenericRec"))
{
var rec = XElement.Parse(rnRecDto.Xml);
var textElt = rec.Element("Text");
if (textElt != null)
{
var objsurElt = textElt.Element("objsur");
if (objsurElt != null && objsurElt.Attribute("t") != null)
{
objsurElt.Attribute("t").SetValue("r");
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, rnRecDto, rec.ToString());
}
}
}
// Remove owner from all Texts
foreach (var textDto in domainObjectDtoRepository.AllInstancesSansSubclasses("Text"))
{
XElement text = XElement.Parse(textDto.Xml);
var ownerAttr = text.Attribute("ownerguid");
if (ownerAttr != null)
{
ownerAttr.Remove();
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, textDto, text.ToString());
}
}
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例12: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Change model for Data Notebook to combine the RnEvent and RnAnalysis classes
/// into RnGenericRec
/// </summary>
/// <param name="domainObjectDtoRepository">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// <remarks>
/// The method must add/remove/update the DTOs to the repository,
/// as it adds/removes objects as part of its work.
///
/// Implementors of this interface should ensure the Repository's
/// starting model version number is correct for the step.
/// Implementors must also increment the Repository's model version number
/// at the end of its migration work.
///
/// The method also should normally modify the xml string(s)
/// of relevant DTOs, since that string will be used by the main
/// data migration calling client (ie. BEP).
/// </remarks>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000004);
// 1. Change EventTypes field to RecTypes
var nbkDto = domainObjectDtoRepository.AllInstancesSansSubclasses("RnResearchNbk").First();
var nbkElement = XElement.Parse(nbkDto.Xml);
var nbkClsElement = nbkElement.Element("RnResearchNbk");
var typesFieldElement = nbkClsElement.Element("EventTypes");
var typesSurElement = typesFieldElement.Element("objsur");
nbkClsElement.Add(new XElement("RecTypes", typesSurElement));
typesFieldElement.Remove();
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, nbkDto, nbkElement.ToString());
// 2. Add Analysis possibility to Record Types list
var typesGuid = typesSurElement.Attribute("guid").Value;
var typesDto = domainObjectDtoRepository.GetDTO(typesGuid);
var typesElement = XElement.Parse(typesDto.Xml);
typesElement.XPathSelectElement("CmMajorObject/Name/AUni[@ws='en']").SetValue("Entry Types");
var posElement = typesElement.XPathSelectElement("CmPossibilityList/Possibilities");
posElement.Add(
DataMigrationServices.CreateOwningObjSurElement("82290763-1633-4998-8317-0EC3F5027FBD"));
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, typesDto,
typesElement.ToString());
var ord = posElement.Elements().Count();
var nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
var typeElement = new XElement("rt", new XAttribute("class", "CmPossibility"),
new XAttribute("guid", "82290763-1633-4998-8317-0EC3F5027FBD"),
new XAttribute("ownerguid", typesGuid),
new XAttribute("owningflid", "8008"), new XAttribute("owningord", ord.ToString()),
new XElement("CmObject"),
new XElement("CmPossibility",
new XElement("Abbreviation",
new XElement("AUni", new XAttribute("ws", "en"), "Ana")),
new XElement("BackColor", new XAttribute("val", "16711680")),
new XElement("DateCreated", new XAttribute("val", nowStr)),
new XElement("DateModified", new XAttribute("val", nowStr)),
new XElement("Description",
new XElement("AStr", new XAttribute("ws", "en"),
new XElement("Run", new XAttribute("ws", "en"), "Reflection on events and other types of data, such as literature summaries or interviews. An analysis does not add data; it interprets and organizes data. An analysis entry may synthesize emerging themes. It may draw connections between observations. It is a place to speculate and hypothesize, or document moments of discovery and awareness. Analytic notes can be turned into articles. Or, they may just be steps on the stairway toward greater understanding."))),
new XElement("ForeColor", new XAttribute("val", "16777215")),
new XElement("Name",
new XElement("AUni", new XAttribute("ws", "en"), "Analysis")),
new XElement("UnderColor", new XAttribute("val", "255")),
new XElement("UnderStyle", new XAttribute("val", "1"))));
domainObjectDtoRepository.Add(new DomainObjectDTO("82290763-1633-4998-8317-0EC3F5027FBD",
"CmPossibility", typeElement.ToString()));
// 3. Move the attributes that are in RnEvent and RnAnalysis into RnGenericRec.
MigrateSubclassOfGenRec(domainObjectDtoRepository, "RnEvent");
MigrateSubclassOfGenRec(domainObjectDtoRepository, "RnAnalysis");
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例13: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// 1) Remove orphaned CmBaseAnnotations, as per FWR-98:
/// "Since we won't try to reuse wfic or segment annotations that no longer have
/// BeginObject point to a paragraph, we should remove (ignore) these annotations
/// when migrating an old database (FW 6.0 or older) into the new architecture"
/// </summary>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000007);
/* Expected data (relevant data, that is) format.
<rt guid="22a8431f-f974-412f-a261-8bd1a4e1be1b" class="CmBaseAnnotation">
<CmObject />
<CmAnnotation>
<AnnotationType> <!-- Entire element will be missing if prop is null. -->
<objsur guid="eb92e50f-ba96-4d1d-b632-057b5c274132" t="r" />
</AnnotationType>
</CmAnnotation>
<CmBaseAnnotation>
<BeginObject> <!-- Entire element will be missing if prop is null. -->
<objsur guid="93dcb15d-f622-4329-b1b5-e5cc832daf01" t="r" />
</BeginObject>
</CmBaseAnnotation>
</rt>
*/
var interestingAnnDefIds = new List<string>
{
DataMigrationServices.kSegmentAnnDefnGuid.ToLower(),
DataMigrationServices.kTwficAnnDefnGuid.ToLower(),
DataMigrationServices.kPficAnnDefnGuid.ToLower(),
DataMigrationServices.kConstituentChartAnnotationAnnDefnGuid.ToLower()
};
//Collect up the ones to be removed.
var goners = new List<DomainObjectDTO>();
foreach (var annDTO in domainObjectDtoRepository.AllInstancesSansSubclasses("CmBaseAnnotation"))
{
var annElement = XElement.Parse(annDTO.Xml);
var typeElement = annElement.Element("CmAnnotation").Element("AnnotationType");
if (typeElement == null
|| !interestingAnnDefIds.Contains(typeElement.Element("objsur").Attribute("guid").Value.ToLower()))
continue; // uninteresing annotation type, so skip it.
// annDTO is a segment, wordform, punctform, or constituent chart annotation.
if (annElement.Element("CmBaseAnnotation").Element("BeginObject") != null)
continue; // Has data in BeginObject property, so skip it.
goners.Add(annDTO);
}
// Remove them.
foreach (var goner in goners)
DataMigrationServices.RemoveIncludingOwnedObjects(domainObjectDtoRepository, goner, true);
// Some stuff may reference the defective Discourse Cahrt Annotation, so clear out the refs to them.
DataMigrationServices.Delint(domainObjectDtoRepository);
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例14: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Change any CmFile filePaths to relative paths which are actually relative to the LinkedFilesRootDir
/// </summary>
/// <param name="domainObjectDtoRepository">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// <remarks>
/// The method must add/remove/update the DTOs to the repository,
/// as it adds/removes objects as part of its work.
///
/// Implementors of this interface should ensure the Repository's
/// starting model version number is correct for the step.
/// Implementors must also increment the Repository's model version number
/// at the end of its migration work.
///
/// The method also should normally modify the xml string(s)
/// of relevant DTOs, since that string will be used by the main
/// data migration calling client (ie. BEP).
/// </remarks>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000028);
var langProjDto = domainObjectDtoRepository.AllInstancesSansSubclasses("LangProject").First();
var langProjElement = XElement.Parse(langProjDto.Xml);
var linkedFilesRootDirElement = langProjElement.Element("LinkedFilesRootDir");
string persistedLinkedFilesRootDir;
if (linkedFilesRootDirElement == null)
{
persistedLinkedFilesRootDir = Path.Combine(domainObjectDtoRepository.ProjectFolder, FdoFileHelper.ksLinkedFilesDir);
}
else
{
persistedLinkedFilesRootDir = linkedFilesRootDirElement.Value;
}
var linkedFilesRootDir = LinkedFilesRelativePathHelper.GetLinkedFilesFullPathFromRelativePath(domainObjectDtoRepository.Directories.ProjectsDirectory,
persistedLinkedFilesRootDir, domainObjectDtoRepository.ProjectFolder);
//Get the Elements for class="CmFile"
var CmFileDtosBeforeMigration = domainObjectDtoRepository.AllInstancesSansSubclasses("CmFile");
foreach (var fileDto in CmFileDtosBeforeMigration)
{
XElement cmFileXML = XElement.Parse(fileDto.Xml);
var filePath = cmFileXML.XPathSelectElement("InternalPath").XPathSelectElement("Uni").Value;
var fileAsRelativePath = LinkedFilesRelativePathHelper.GetRelativeLinkedFilesPath(filePath,
linkedFilesRootDir);
//If these two strings do not match then a full path was converted to a LinkedFiles relative path
//so replace the path in the CmFile object.
// (If fileAsRelativePath is null, we could not make sense of the path at all; it may be corrupt.
// Certainly we can't improve it!)
if (fileAsRelativePath != null && !String.Equals(fileAsRelativePath, filePath))
{
cmFileXML.XPathSelectElement("InternalPath").XPathSelectElement("Uni").Value = fileAsRelativePath;
UpdateDto(domainObjectDtoRepository, fileDto, cmFileXML);
}
}
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例15: PerformMigration
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000065);
// Cache all basic data properties for each class in the mdc.
var mdc = domainObjectDtoRepository.MDC;
var cachedBasicProperties = CacheBasicProperties(mdc);
foreach (var kvp in cachedBasicProperties)
{
var className = kvp.Key;
if (mdc.GetAbstract(mdc.GetClassId(className)))
continue; // Won't find any of those as dtos.
var basicProps = kvp.Value;
foreach (var dto in domainObjectDtoRepository.AllInstancesSansSubclasses(className))
{
var rootElementChanged = false;
var rootElement = XElement.Parse(dto.Xml);
foreach (var basicPropertyInfo in basicProps)
{
if (basicPropertyInfo.m_isCustom)
{
var customPropElement = rootElement.Elements("Custom").FirstOrDefault(element => element.Attribute("name").Value == basicPropertyInfo.m_propertyName);
if (customPropElement == null)
{
CreateCustomProperty(rootElement, basicPropertyInfo);
rootElementChanged = true;
}
}
else
{
var basicPropertyElement = rootElement.Element(basicPropertyInfo.m_propertyName);
if (basicPropertyElement == null && !SkipTheseBasicPropertyNames.Contains(basicPropertyInfo.m_propertyName) && !basicPropertyInfo.m_isVirtual)
{
CreateBasicProperty(rootElement, basicPropertyInfo);
rootElementChanged = true;
}
}
}
if (!rootElementChanged)
continue;
dto.Xml = rootElement.ToString();
domainObjectDtoRepository.Update(dto);
}
}
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}