mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-23 23:55:38 +03:00
2511 lines
133 KiB
C++
2511 lines
133 KiB
C++
#include "s1000d_manager.h"
|
||
#include <QString>
|
||
#include <QDir>
|
||
#include <QFileInfo>
|
||
#include <QFile>
|
||
#include <QXmlStreamWriter>
|
||
#include <QXmlStreamReader>
|
||
#include <QXmlStreamAttribute>
|
||
//#include <QtXmlPatterns/QXmlSchemaValidator>
|
||
//#include <QtXmlPatterns/QXmlSchema>
|
||
//#include <QtXmlPatterns/QtXmlPatterns>
|
||
#include <QDebug>
|
||
#include <QMessageBox>
|
||
|
||
// DM: Chapter 3.9.5.2.1.2 Common constructs
|
||
// ICN: 1822
|
||
|
||
// большинство функций работают с текущим элементом списка, хранимым в item
|
||
// ВСЕГДА сначала необходимо вызывать setCurItem(int ind)
|
||
|
||
S1000D_Manager::S1000D_Manager()
|
||
{
|
||
ru_const.Init_RU_Const();
|
||
}
|
||
|
||
S1000D_Manager::~S1000D_Manager()
|
||
{
|
||
clearItems();
|
||
}
|
||
|
||
|
||
QDomNode S1000D_Manager::findElementRec(QDomNode domNode, QString path) {
|
||
QStringList elementTagNames = path.split('.');
|
||
QDomNodeList domNodeList = domNode.childNodes();
|
||
|
||
//if(DBG) qDebug() << path;
|
||
if(elementTagNames.isEmpty() || path == "")
|
||
return domNode;
|
||
int nodeInd = getNodePathIndex(elementTagNames.first());
|
||
QString nodeName = elementTagNames.first();
|
||
if(nodeName.indexOf("[") != -1)
|
||
nodeName = nodeName.mid(0, nodeName.indexOf("["));
|
||
//if(DBG) qDebug() << " " << elementTagNames.first() << " -> " << nodeName << "[" << nodeInd << "]" << " childs " << domNodeList.count();
|
||
|
||
for(int i = 0; i < domNodeList.count(); i++) {
|
||
//if(DBG) qDebug() << " search for" << nodeName << "=?" << domNodeList.at(i).nodeName();
|
||
if(domNodeList.at(i).nodeName().compare(nodeName,Qt::CaseInsensitive) == 0) { //toElement().tagName().
|
||
if(nodeInd > 0) {
|
||
nodeInd--; continue;
|
||
}
|
||
|
||
elementTagNames.takeFirst();
|
||
if(elementTagNames.isEmpty())
|
||
return domNodeList.at(i);
|
||
else
|
||
return findElementRec(domNodeList.at(i), elementTagNames.join("."));
|
||
}
|
||
}
|
||
|
||
//if(DBG) qDebug() << " Node " << elementTagNames.at(0) << " not found (" << path << ")";
|
||
QDomElement nullElement = item->doc.createElement("");
|
||
return nullElement;
|
||
|
||
//QDomElement newElement = item->doc.createElement(elementTagNames.at(0)); // если узел отсутствует - создаем
|
||
//elementTagNames.takeFirst();
|
||
//domNode.appendChild(newElement);
|
||
//return findElementRec(newElement,elementTagNames.join("."));
|
||
}
|
||
|
||
QDomNode S1000D_Manager::findElement(QString path) {
|
||
//if(DBG) qDebug() << item->doc.documentElement().tagName();
|
||
//if(DBG) qDebug() << " findElement " << path;
|
||
return findElementRec(item->doc.documentElement(), path);
|
||
}
|
||
|
||
QString S1000D_Manager::getNodeText(QString path) {
|
||
QDomNode element = findElement(path);
|
||
if(element.isNull())
|
||
return "";
|
||
else
|
||
return element.toElement().text();
|
||
}
|
||
|
||
void S1000D_Manager::setNodeText(QString path, QString text) {
|
||
QDomNode element = findElement(path);
|
||
if(element.isNull()) return;
|
||
//if(DBG) qDebug() << " element: " << element.firstChild().isText() << element.nodeName();
|
||
for(QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling())
|
||
{
|
||
QDomText t = n.toText();
|
||
if (!t.isNull())
|
||
t.setNodeValue(text);
|
||
}
|
||
if(element.childNodes().count() == 0) {
|
||
QDomText t = item->doc.createTextNode(text);
|
||
element.appendChild(t);
|
||
}
|
||
}
|
||
|
||
void S1000D_Manager::deleteNode(QString path) {
|
||
QDomNode element = findElement(path);
|
||
if(element.isNull()) return;
|
||
element.parentNode().removeChild(element);
|
||
}
|
||
|
||
int S1000D_Manager::createNode(QString path, QString nodeName) { // возвращает номер созданного узла для обращения по индексу: node[i]
|
||
QDomNode element = findElement(path);
|
||
if(element.isNull()) return -1;
|
||
QDomElement newNode = item->doc.createElement(nodeName);
|
||
element.appendChild(newNode);
|
||
QDomNodeList lst = element.childNodes();
|
||
int index = -1;
|
||
for(int i=0; i<lst.count();i++) {
|
||
if(lst.at(i).nodeName() == nodeName) index++;
|
||
if(lst.at(i) == newNode)
|
||
return index;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
bool S1000D_Manager::isNodeCreated(QString path) {
|
||
bool tmp = DBG; DBG = false;
|
||
QDomNode element = findElement(path);
|
||
DBG = tmp;
|
||
if(element.isNull())
|
||
return false;
|
||
else
|
||
return true;
|
||
}
|
||
|
||
QString S1000D_Manager::getNodeAttr(QString path, QString attrName) {
|
||
QDomNode element = findElement(path);
|
||
if(element.isNull()) return "";
|
||
return element.toElement().attribute(attrName);
|
||
}
|
||
|
||
void S1000D_Manager::setNodeAttr(QString path, QString attrName, QString attrVal) {
|
||
QDomNode element = findElement(path);
|
||
if(element.isNull()) return;
|
||
//if(DBG) qDebug() << " setNodeAttr: " << element.hasAttributes() << element.nodeName() << attrName << element.toElement().attribute(attrName);
|
||
element.toElement().setAttribute(attrName, attrVal);
|
||
//if(DBG) qDebug() << " " << element.hasAttributes() << element.nodeName() << attrName << element.toElement().attribute(attrName);
|
||
|
||
/*if(element.toElement().hasAttribute(attrName)) {
|
||
element.toElement().setAttribute(attrName, attrVal);
|
||
} else {
|
||
QDomAttr domAttr = item->doc.createAttribute(attrName);
|
||
domAttr.setValue(attrVal);
|
||
element.toElement().setAttributeNode(domAttr);
|
||
} */
|
||
}
|
||
|
||
void S1000D_Manager::deleteNodeAttr(QString path, QString attrName) {
|
||
QDomNode element = findElement(path);
|
||
if(element.isNull()) return;
|
||
element.toElement().removeAttribute(attrName);
|
||
}
|
||
|
||
QStringList S1000D_Manager::getNodeAllChilds(QString path) {
|
||
QStringList nodeList;
|
||
QDomNode element = findElement(path);
|
||
if(element.isNull()) return nodeList;
|
||
|
||
QDomNodeList domNodeList = element.childNodes();
|
||
for(int i=0;i<domNodeList.count(); i++) {
|
||
nodeList.append(domNodeList.at(i).nodeName());
|
||
}
|
||
return nodeList;
|
||
}
|
||
|
||
int S1000D_Manager::getNodeChildsWithNameCount(QString path, QString childNodeName) {
|
||
int cnt = 0;
|
||
QStringList nodeList;
|
||
QDomNode element = findElement(path);
|
||
if(element.isNull()) return cnt;
|
||
|
||
QDomNodeList domNodeList = element.childNodes();
|
||
for(int i=0;i<domNodeList.count(); i++)
|
||
if(domNodeList.at(i).nodeName().compare(childNodeName,Qt::CaseInsensitive) == 0)
|
||
cnt++;
|
||
return cnt;
|
||
}
|
||
|
||
int S1000D_Manager::getNodePathIndex(QString name) {
|
||
if(name.indexOf("[") == -1) return 0;
|
||
return name.mid(name.indexOf("[")+1, name.indexOf("]")-name.indexOf("[")-1).toInt();
|
||
}
|
||
|
||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OPEN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
||
bool S1000D_Manager::OpenProjectDirectory(const QString& prPath, QString& _) //schemasPath
|
||
{
|
||
return false; // это старый подход
|
||
/*
|
||
log.clear(); log.append(QString("Открытие проекта ")+prPath);
|
||
projectPath = prPath; //projectPath.replace("\\", "/");
|
||
QDir dir(prPath);
|
||
QList <QString> mask;
|
||
mask.append(QString("*.xml"));
|
||
QStringList listFiles = dir.entryList(mask, QDir::Files);
|
||
//bool validFlag;
|
||
clearItems();
|
||
|
||
foreach (QString file, listFiles) {
|
||
item = new ItemStruct();
|
||
item->fileName = dir.absoluteFilePath(file); item->isReady = true;
|
||
//log.append(QFileInfo(file).fileName());
|
||
//if(DBG) qDebug() << "Открытие " << QFileInfo(file).fileName();
|
||
|
||
QFile xmlFile(item->fileName);
|
||
if (!xmlFile.open(QFile::ReadOnly | QFile::Text)) {
|
||
log.append(QString(" Не удалось открыть файл"));
|
||
continue;
|
||
}
|
||
QByteArray fileData = xmlFile.readAll();
|
||
xmlFile.close();
|
||
item->doc.setContent(fileData);
|
||
|
||
QString curscheme = QFileInfo(item->doc.documentElement().attribute("xsi:noNamespaceSchemaLocation", "")).baseName().toUpper();
|
||
item->moduleType = mtUNKNOWN;
|
||
if(item->doc.documentElement().nodeName().toUpper() == "DMODULE")
|
||
item->moduleType = mtDM;
|
||
if(item->doc.documentElement().nodeName().toUpper() == "PM")
|
||
item->moduleType = mtPM;
|
||
|
||
//log.append(QString(" Тип модуля: ")+item->doc.documentElement().nodeName() + QString(" Файл схемы: ")+curscheme);
|
||
//if(DBG) qDebug() << " Тип модуля: " << item->doc.documentElement().nodeName() << " Файл схемы: " << curscheme;
|
||
|
||
// Доп. ТЗ № 1 Вертолеты России:
|
||
// Резрешено использовать только flat схемы, перечисленные ниже:
|
||
// - brex
|
||
// - comrep
|
||
// - crew
|
||
// - descript
|
||
// - dml
|
||
// - fault
|
||
// - frontmatter
|
||
// - learning
|
||
// - pm
|
||
// - proced
|
||
|
||
item->schemeType = getSchemeTypeByStr(curscheme);
|
||
|
||
if(item->moduleType == mtUNKNOWN) {
|
||
//log.append(QString(" Тип модуля не поддерживается, файл пропущен"));
|
||
continue;
|
||
}
|
||
if(item->schemeType == stUNKNOWN) {
|
||
//log.append(QString(" Неизвестная схема файла, пропущен"));
|
||
continue;
|
||
}
|
||
|
||
//if((item->schemeType != PM) && (item->schemeType != DESCRIPT) &&
|
||
// (item->schemeType != CREW) && (item->schemeType != LEARNING) ) {
|
||
// log.append(QString(" Работа с файлами схемы " +curscheme+ " в настоящее время не реализована, файл пропущен"));
|
||
// continue;
|
||
//}
|
||
|
||
item->fileCode = "";
|
||
// DMC-S1000DLIGHTING-AAA-D00-00-00-00AA-0A1A-D_001-00_EN-US
|
||
//<dc:identifier>S1000DLIGHTING-AAA-D00-00-00-00AA-00NA-D_001-00</dc:identifier>
|
||
//dmodule <dmCode modelIdentCode="S1000DLIGHTING" systemDiffCode="AAA" systemCode="D00" subSystemCode="0" subSubSystemCode="0" assyCode="00" disassyCode="00" disassyCodeVariant="AA" infoCode="0A1" infoCodeVariant="A" itemLocationCode="D"/>
|
||
// <language languageIsoCode="en" countryIsoCode="US"/>
|
||
// <issueInfo issueNumber="001" inWork="00"/>
|
||
QString _language; //_dmCode, _issueInfo, , _pmCode;
|
||
QString newFileName = item->fileName;
|
||
if(item->moduleType == mtDM) {
|
||
item->fileCode = dmIdentString("identAndStatusSection.dmAddress.dmIdent");
|
||
if(!isNodeCreated("rdf:Description")) {
|
||
QDomNode descr = item->doc.createElement("rdf:Description");
|
||
findElement("").insertBefore(descr, findElement("").firstChild());
|
||
}
|
||
if(!isNodeCreated("rdf:Description.dc:identifier")) createNode("rdf:Description", "dc:identifier");
|
||
setNodeText("rdf:Description.dc:identifier", item->fileCode);
|
||
_language = "identAndStatusSection.dmAddress.dmIdent.language";
|
||
newFileName = QFileInfo(item->fileName).absolutePath()+"/" + "DMC-" + item->fileCode + "_"+getNodeAttr(_language, "languageIsoCode").toUpper()+"-"+getNodeAttr(_language, "countryIsoCode").toUpper()+".xml";
|
||
item->dmDataFilled = true; item->selectedInDMCodeList = -1;
|
||
}
|
||
|
||
// PMC-BRAKE-C3002-EPWG1-00_000-01_EN-US
|
||
// <dc:identifier>BRAKE-C3002-EPWG1-00_000_01</dc:identifier>
|
||
//<pmCode modelIdentCode="BRAKE" pmIssuer="C3002" pmNumber="EPWG1" pmVolume="00"/>
|
||
//<issueInfo issueNumber="000" inWork="01"/>
|
||
if(item->moduleType == mtPM) {
|
||
//_pmCode = "identAndStatusSection.pmAddress.pmIdent.pmCode";
|
||
//_issueInfo = "identAndStatusSection.pmAddress.pmIdent.issueInfo";
|
||
_language = "identAndStatusSection.pmAddress.pmIdent.language";
|
||
item->fileCode = pmIdentString("identAndStatusSection.pmAddress.pmIdent");
|
||
if(!isNodeCreated("rdf:Description")) {
|
||
QDomNode descr = item->doc.createElement("rdf:Description");
|
||
findElement("").insertBefore(descr, findElement("").firstChild());
|
||
}
|
||
if(!isNodeCreated("rdf:Description.dc:identifier")) createNode("rdf:Description", "dc:identifier");
|
||
setNodeText("rdf:Description.dc:identifier", item->fileCode);
|
||
newFileName = QFileInfo(item->fileName).absolutePath()+"/" + "PMC-" + item->fileCode + "_"+getNodeAttr(_language, "languageIsoCode").toUpper()+"-"+getNodeAttr(_language, "countryIsoCode").toUpper()+".xml";
|
||
}
|
||
|
||
if(isNodeCreated("rdf:Description.dc:source"))
|
||
item->importedFromLyX = getNodeText("rdf:Description.dc:source");
|
||
else
|
||
item->importedFromLyX = "";
|
||
|
||
if(QFileInfo(newFileName.toUpper()).fileName() != QFileInfo(item->fileName.toUpper()).fileName())
|
||
if(QFileInfo::exists(item->fileName)) {
|
||
QFile::rename(item->fileName, newFileName);
|
||
log.append(QString(" Файл переименован в " + QFileInfo(newFileName).fileName()));
|
||
item->fileName = newFileName;
|
||
}
|
||
|
||
item->parent = -1; item->child.clear();
|
||
//if(DBG) qDebug() << item->fileCode;
|
||
|
||
items.append(*item); // файл прочтен успешно, добавляем в список
|
||
} // цикл по файлам
|
||
|
||
for(int i=0;i<items.count();i++) {
|
||
if(items[i].moduleType == mtPM)
|
||
buildPMTree(i);
|
||
}
|
||
|
||
// в DM Learning в узлах lcInteraction делаем только один child (вопрос)
|
||
QDomNode lcInteractionNode, nodeClone;
|
||
QDomElement newInter;
|
||
for(int i=0;i<items.count();i++)
|
||
if(items[i].schemeType == stLEARNING) {
|
||
setCurItem(i);
|
||
int interCnt = getNodeChildsWithNameCount("content.learning.learningAssessment", "lcInteraction");
|
||
for(int j=0;j<interCnt;j++) {
|
||
lcInteractionNode = findElement("content.learning.learningAssessment.lcInteraction["+QString::number(j)+"]");
|
||
while(lcInteractionNode.childNodes().count() > 1) {
|
||
nodeClone = lcInteractionNode.lastChild().cloneNode();
|
||
lcInteractionNode.removeChild(lcInteractionNode.lastChild());
|
||
newInter = item->doc.createElement("lcInteraction");
|
||
newInter.appendChild(nodeClone);
|
||
lcInteractionNode.parentNode().insertAfter(newInter, lcInteractionNode);
|
||
interCnt++;
|
||
}
|
||
}
|
||
}
|
||
|
||
return true;
|
||
*/
|
||
}
|
||
|
||
_schemeType S1000D_Manager::getSchemeTypeByStr(QString str) {
|
||
_schemeType newSchemeType = stUNKNOWN;
|
||
if(str == "DDN") newSchemeType = stDDN;
|
||
if(str == "DML") newSchemeType = stDML;
|
||
if(str == "PM") newSchemeType = stPM;
|
||
if(str == "APPLICCROSSREFTABLE") newSchemeType = stAPPLICCROSSREFTABLE;
|
||
if(str == "PRDCROSSREFTABLE") newSchemeType = stPRDCROSSREFTABLE;
|
||
if(str == "CONDCROSSREFTABLE") newSchemeType = stCONDCROSSREFTABLE;
|
||
if(str == "DESCRIPT") newSchemeType = stDESCRIPT;
|
||
if(str == "PROCED") newSchemeType = stPROCED;
|
||
if(str == "PROCESS") newSchemeType = stPROCESS;
|
||
if(str == "COMREP") newSchemeType = stCOMREP;
|
||
if(str == "FRONTMATTER") newSchemeType = stFRONTMATTER;
|
||
if(str == "BREX") newSchemeType = stBREX;
|
||
if(str == "BRDOC") newSchemeType = stBRDOC;
|
||
if(str == "LEARNING") newSchemeType = stLEARNING;
|
||
if(str == "CREW") newSchemeType = stCREW;
|
||
if(str == "FAULT") newSchemeType = stFAULT;
|
||
if(str == "IPD") newSchemeType = stIPD;
|
||
if(str == "CHECKLIST") newSchemeType = stCHECKLIST;
|
||
if(str == "NOTATIONS") newSchemeType = stNOTATIONS;
|
||
if(str == "CONTAINER") newSchemeType = stCONTAINER;
|
||
if(str == "XLINK") newSchemeType = stXLINK;
|
||
if(str == "WRNGFLDS") newSchemeType = stWRNGFLDS;
|
||
return newSchemeType;
|
||
}
|
||
|
||
void S1000D_Manager::buildPMTree(int pmItemInd) {
|
||
setCurItem(pmItemInd);
|
||
|
||
bool isModifyed = false;
|
||
QString PMCodeStr, DMCodeStr;
|
||
QDomNode mainEntry, secondEntry, clone, subEntry, subSubEntry;
|
||
mainEntry = findElement("content.pmEntry[0]");
|
||
if(mainEntry.isNull()) return;
|
||
|
||
while(isNodeCreated("content.pmEntry[1]")) {
|
||
secondEntry = findElement("content.pmEntry[1]");
|
||
while(secondEntry.hasChildNodes()) {
|
||
if(secondEntry.firstChild().nodeName() == "dmRef" || secondEntry.firstChild().nodeName() == "pmRef") {
|
||
clone = secondEntry.firstChild().cloneNode();
|
||
item->doc.importNode(clone, true);
|
||
mainEntry.appendChild(clone);
|
||
}
|
||
if(secondEntry.firstChild().nodeName() == "pmEntry") {
|
||
subEntry = secondEntry.firstChild();
|
||
while(subEntry.hasChildNodes()) {
|
||
if(subEntry.firstChild().nodeName() == "dmRef" || subEntry.firstChild().nodeName() == "pmRef") {
|
||
clone = subEntry.firstChild().cloneNode();
|
||
item->doc.importNode(clone, true);
|
||
mainEntry.appendChild(clone);
|
||
}
|
||
if(subEntry.firstChild().nodeName() == "pmEntry") {
|
||
subSubEntry = secondEntry.firstChild();
|
||
while(subSubEntry.hasChildNodes()) {
|
||
if(subSubEntry.firstChild().nodeName() == "dmRef" || subSubEntry.firstChild().nodeName() == "pmRef") {
|
||
clone = subSubEntry.firstChild().cloneNode();
|
||
item->doc.importNode(clone, true);
|
||
mainEntry.appendChild(clone);
|
||
}
|
||
//..
|
||
subSubEntry.removeChild(subEntry.firstChild());
|
||
}
|
||
subEntry.removeChild(subEntry.firstChild());
|
||
}
|
||
}
|
||
}
|
||
secondEntry.removeChild(secondEntry.firstChild());
|
||
}
|
||
mainEntry.parentNode().removeChild(secondEntry);
|
||
}
|
||
|
||
int pmRefCnt=-1, dmRefCnt=-1;
|
||
for(int p=0;p<mainEntry.childNodes().count();p++) {
|
||
if(mainEntry.childNodes().at(p).nodeName() == "pmRef") {
|
||
pmRefCnt++;
|
||
PMCodeStr = pmIdentString("content.pmEntry.pmRef["+QString::number(pmRefCnt)+"].pmRefIdent");
|
||
//if(DBG) qDebug() << " pmRef: " << PMCodeStr;
|
||
bool foundParent = false;
|
||
for(int j=0; j<items.count();j++)
|
||
if((items[j].moduleType == mtPM) && (items[j].fileCode.compare(PMCodeStr, Qt::CaseInsensitive) == 0)) {
|
||
// включаем элемент j как child элемента parent
|
||
items[pmItemInd].child.append(j);
|
||
items[j].parent = pmItemInd;
|
||
foundParent = true; break;
|
||
}
|
||
if(!foundParent) { // нет item по ссылке pmRef, удаляем узел Ref
|
||
deleteNode("content.pmEntry.pmRef["+QString::number(pmRefCnt)+"]");
|
||
pmRefCnt--; p--; isModifyed = true;
|
||
}
|
||
}
|
||
if(mainEntry.childNodes().at(p).nodeName() == "dmRef") {
|
||
dmRefCnt++;
|
||
DMCodeStr = dmIdentString("content.pmEntry.dmRef["+QString::number(dmRefCnt)+"].dmRefIdent");
|
||
//if(DBG) qDebug() << " dmRef: " << DMCodeStr;
|
||
bool foundParent = false;
|
||
for(int j=0; j<items.count();j++)
|
||
if((items[j].moduleType == mtDM) && (items[j].fileCode.compare(DMCodeStr, Qt::CaseInsensitive) == 0)) {
|
||
// включаем элемент j как child элемента parent
|
||
items[pmItemInd].child.append(j);
|
||
//if(items[j].parent != -1) if(DBG) qDebug() << " parents: " << items[j].parent << parent;
|
||
items[j].parent = pmItemInd;
|
||
foundParent = true; break;
|
||
}
|
||
if(!foundParent) { // нет item по ссылке dmRef, удаляем узел Ref
|
||
deleteNode("content.pmEntry.dmRef["+QString::number(pmRefCnt)+"]");
|
||
dmRefCnt--; p--; isModifyed = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
// int cntEntry = getNodeChildsWithNameCount(path, "pmEntry");
|
||
// QString PMCodeStr, DMCodeStr;
|
||
// for(int i=0; i<cntEntry;i++) { // цикл по pmEntry
|
||
// setCurItem(parent);
|
||
|
||
// // немного упрощаем требования стандарта (при необходимости доделать)
|
||
// // избавляемся от сложной структуры pmEntry.pmEntry, переносим всех детей (без <pmEntryTitle>!) в основную pmEntry
|
||
// QDomNode mainEntry, subEntry;
|
||
// QDomNodeList subEntryChildList;
|
||
// while(isNodeCreated(path+".pmEntry["+QString::number(i)+"].pmEntry")) {
|
||
// mainEntry = findElement(path+".pmEntry["+QString::number(i)+"]");
|
||
|
||
// int subEntryCnt = getNodeChildsWithNameCount(path+".pmEntry["+QString::number(i)+"]", "pmEntry");
|
||
// for(int j=0;j<subEntryCnt;j++) {
|
||
// subEntry = findElement(path+".pmEntry["+QString::number(i)+"].pmEntry[0]");
|
||
// subEntryChildList = subEntry.childNodes();
|
||
// for(int k=0;k<subEntryChildList.count();k++) {
|
||
// if(subEntryChildList.at(k).nodeName() == "pmEntryTitle") {
|
||
// subEntry.removeChild(subEntryChildList.at(k)); //
|
||
// continue;
|
||
// }
|
||
// QDomNode subEntryChildClone = subEntryChildList.at(k).cloneNode();
|
||
// mainEntry.appendChild(subEntryChildClone);
|
||
// subEntry.removeChild(subEntryChildList.at(k)); //
|
||
// }
|
||
// mainEntry.removeChild(subEntry);
|
||
// isModifyed = true;
|
||
// }
|
||
// }
|
||
|
||
// //int cntRef = getNodeChildsWithNameCount(path+".pmEntry["+QString::number(i)+"]", "pmRef")
|
||
// // +getNodeChildsWithNameCount(path+".pmEntry["+QString::number(i)+"]", "dmRef");
|
||
// int pmRefCnt=-1, dmRefCnt=-1;
|
||
// mainEntry = findElement(path+".pmEntry["+QString::number(i)+"]");
|
||
|
||
// for(int p=0;p<mainEntry.childNodes().count();p++) {
|
||
// if(mainEntry.childNodes().at(p).nodeName() == "pmRef") {
|
||
// pmRefCnt++;
|
||
// PMCodeStr = pmIdentString(path+".pmEntry["+QString::number(i)+"].pmRef["+QString::number(pmRefCnt)+"].pmRefIdent");
|
||
// //if(DBG) qDebug() << " pmRef: " << PMCodeStr;
|
||
// bool foundParent = false;
|
||
// for(int j=0; j<items.count();j++)
|
||
// if((items[j].moduleType == mtPM) && (items[j].fileCode.compare(PMCodeStr, Qt::CaseInsensitive) == 0)) {
|
||
// // включаем элемент j как child элемента parent
|
||
// items[parent].child.append(j);
|
||
// items[j].parent = parent;
|
||
// foundParent = true; break;
|
||
// }
|
||
// if(!foundParent) { // нет item по ссылке pmRef, удаляем узел Ref
|
||
// deleteNode(path+".pmEntry["+QString::number(i)+"].pmRef["+QString::number(pmRefCnt)+"]");
|
||
// pmRefCnt--; p--; isModifyed = true;
|
||
// }
|
||
// }
|
||
// if(mainEntry.childNodes().at(p).nodeName() == "dmRef") {
|
||
// dmRefCnt++;
|
||
// DMCodeStr = dmIdentString(path+".pmEntry["+QString::number(i)+"].dmRef["+QString::number(dmRefCnt)+"].dmRefIdent");
|
||
// //if(DBG) qDebug() << " dmRef: " << DMCodeStr;
|
||
// bool foundParent = false;
|
||
// for(int j=0; j<items.count();j++)
|
||
// if((items[j].moduleType == mtDM) && (items[j].fileCode.compare(DMCodeStr, Qt::CaseInsensitive) == 0)) {
|
||
// // включаем элемент j как child элемента parent
|
||
// items[parent].child.append(j);
|
||
// //if(items[j].parent != -1) if(DBG) qDebug() << " parents: " << items[j].parent << parent;
|
||
// items[j].parent = parent;
|
||
// foundParent = true; break;
|
||
// }
|
||
// if(!foundParent) { // нет item по ссылке dmRef, удаляем узел Ref
|
||
// deleteNode(path+".pmEntry["+QString::number(i)+"].dmRef["+QString::number(pmRefCnt)+"]");
|
||
// dmRefCnt--; p--; isModifyed = true;
|
||
// }
|
||
// }
|
||
// }
|
||
|
||
// //if(isNodeCreated(path+".pmEntry["+QString::number(i)+"].pmEntry")) - уже не требуется, от pmEntry.pmEntry избавились выше
|
||
// // buildPMTree(parent, path+".pmEntry");
|
||
// } //pmEntry
|
||
|
||
if(isModifyed) SaveProject();
|
||
}
|
||
|
||
QString S1000D_Manager::dmIdentString(QString dmIdentPath) {
|
||
QString resStr = "";
|
||
resStr += getNodeAttr(dmIdentPath+".dmCode", "modelIdentCode")+"-";
|
||
resStr += getNodeAttr(dmIdentPath+".dmCode", "systemDiffCode")+"-";
|
||
resStr += getNodeAttr(dmIdentPath+".dmCode", "systemCode")+"-";
|
||
resStr += getNodeAttr(dmIdentPath+".dmCode", "subSystemCode");
|
||
resStr += getNodeAttr(dmIdentPath+".dmCode", "subSubSystemCode")+"-";
|
||
resStr += getNodeAttr(dmIdentPath+".dmCode", "assyCode")+"-";
|
||
resStr += getNodeAttr(dmIdentPath+".dmCode", "disassyCode");
|
||
resStr += getNodeAttr(dmIdentPath+".dmCode", "disassyCodeVariant")+"-";
|
||
resStr += getNodeAttr(dmIdentPath+".dmCode", "infoCode");
|
||
resStr += getNodeAttr(dmIdentPath+".dmCode", "infoCodeVariant")+"-";
|
||
resStr += getNodeAttr(dmIdentPath+".dmCode", "itemLocationCode");
|
||
//if(resStr == "-------") if(DBG) qDebug() << " Warning: dmIdentString == -------";
|
||
QString learnStr = "-"+getNodeAttr(dmIdentPath+".dmCode", "learnCode")+getNodeAttr(dmIdentPath+".dmCode", "learnEventCode");
|
||
if(learnStr != "-") resStr += learnStr;
|
||
//resStr += "_"+getNodeAttr(dmIdentPath+".issueInfo", "issueNumber")+"-";
|
||
//resStr += getNodeAttr(dmIdentPath+".issueInfo", "inWork");
|
||
return resStr;
|
||
}
|
||
QString S1000D_Manager::dmCodeIdentString(QDomNode node) {
|
||
QString resStr = "";
|
||
resStr += node.toElement().attribute("modelIdentCode")+"-";
|
||
resStr += node.toElement().attribute("systemDiffCode")+"-";
|
||
resStr += node.toElement().attribute("systemCode")+"-";
|
||
resStr += node.toElement().attribute("subSystemCode");
|
||
resStr += node.toElement().attribute("subSubSystemCode")+"-";
|
||
resStr += node.toElement().attribute("assyCode")+"-";
|
||
resStr += node.toElement().attribute("disassyCode");
|
||
resStr += node.toElement().attribute("disassyCodeVariant")+"-";
|
||
resStr += node.toElement().attribute("infoCode");
|
||
resStr += node.toElement().attribute("infoCodeVariant")+"-";
|
||
resStr += node.toElement().attribute("itemLocationCode");
|
||
QString learnStr = "-"+node.toElement().attribute("learnCode")+node.toElement().attribute("learnEventCode");
|
||
if(learnStr != "-") resStr += learnStr;
|
||
return resStr;
|
||
}
|
||
|
||
QString S1000D_Manager::pmIdentString(QString pmIdentPath) {
|
||
QString resStr = "";
|
||
resStr += getNodeAttr(pmIdentPath+".pmCode", "modelIdentCode")+"-";
|
||
resStr += getNodeAttr(pmIdentPath+".pmCode", "pmIssuer")+"-";
|
||
resStr += getNodeAttr(pmIdentPath+".pmCode", "pmNumber")+"-";
|
||
resStr += getNodeAttr(pmIdentPath+".pmCode", "pmVolume")+"_";
|
||
resStr += getNodeAttr(pmIdentPath+".issueInfo", "issueNumber")+"-";
|
||
resStr += getNodeAttr(pmIdentPath+".issueInfo", "inWork");
|
||
return resStr;
|
||
}
|
||
|
||
void S1000D_Manager::clearItems()
|
||
{
|
||
//for(int i=0; i<items.count();i++) {
|
||
//delete &items[i]; - нет необходимости
|
||
//}
|
||
items.clear(); item = nullptr;
|
||
}
|
||
|
||
void S1000D_Manager::prepareSaveProject() {
|
||
return; // пока нет необходимости
|
||
|
||
/*for(int i=0;i<items.count();i++) {
|
||
setCurItem(i);
|
||
item->fileCode = ""; // если изменилось кодирование модулей - переименовываем старые файлы
|
||
QString _issueInfo, _language;
|
||
QString newFileName = item->fileName;
|
||
if(item->moduleType == mtDM) {
|
||
|
||
item->fileCode = dmIdentString("identAndStatusSection.dmAddress.dmIdent");
|
||
_issueInfo = "identAndStatusSection.dmAddress.dmIdent.issueInfo";
|
||
_language = "identAndStatusSection.dmAddress.dmIdent.language";
|
||
newFileName = QFileInfo(item->fileName).absolutePath()+"/" + "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".xml";
|
||
}
|
||
if(item->moduleType == mtPM) {
|
||
_issueInfo = "identAndStatusSection.pmAddress.pmIdent.issueInfo";
|
||
_language = "identAndStatusSection.pmAddress.pmIdent.language";
|
||
item->fileCode = pmIdentString("identAndStatusSection.pmAddress.pmIdent");
|
||
newFileName = QFileInfo(item->fileName).absolutePath()+"/" + "PMC-" + item->fileCode + "_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".xml";
|
||
}
|
||
|
||
if(QFileInfo(newFileName.toUpper()).fileName() != QFileInfo(item->fileName.toUpper()).fileName())
|
||
if(QFileInfo::exists(item->fileName)) {
|
||
QFile::rename(item->fileName, newFileName);
|
||
log.append(QString(" Файл "+QFileInfo(item->fileName).fileName()+" переименован в " + QFileInfo(newFileName).fileName()));
|
||
}
|
||
item->fileName = newFileName;
|
||
} */
|
||
}
|
||
|
||
void S1000D_Manager::SaveProject() {
|
||
qSetGlobalQHashSeed(0);
|
||
for(int i=0;i<items.count();i++) {
|
||
setCurItem(i);
|
||
if(item->moduleType == mtDM) {
|
||
item->fileCode = dmIdentString("identAndStatusSection.dmAddress.dmIdent");
|
||
QDomNode descr = item->doc.namedItem("dmodule").namedItem("rdf:Description");
|
||
if(descr.isNull()) {
|
||
descr = item->doc.createElement("rdf:Description");
|
||
item->doc.namedItem("dmodule").insertBefore(descr, item->doc.namedItem("dmodule").namedItem("identAndStatusSection"));
|
||
}
|
||
//descr.toElement().setAttribute("flags", QString::number(item->crewFlags, 16));
|
||
if(item->isQualifyed)
|
||
descr.toElement().setAttribute("qualifyed", "true");
|
||
else
|
||
descr.toElement().setAttribute("qualifyed", "false");
|
||
}
|
||
if(item->moduleType == mtPM) {
|
||
item->fileCode = pmIdentString("identAndStatusSection.pmAddress.pmIdent");
|
||
QDomNode descr = item->doc.namedItem("pm").namedItem("rdf:Description");
|
||
if(descr.isNull()) {
|
||
descr = item->doc.createElement("rdf:Description");
|
||
item->doc.namedItem("pm").insertBefore(descr, item->doc.namedItem("pm").namedItem("identAndStatusSection"));
|
||
}
|
||
//descr.toElement().setAttribute("flags", QString::number(item->crewFlags, 16));
|
||
if(item->isQualifyed)
|
||
descr.toElement().setAttribute("qualifyed", "true");
|
||
else
|
||
descr.toElement().setAttribute("qualifyed", "false");
|
||
}
|
||
|
||
QFile xmlFile(projectPath + "/" + item->fileName);
|
||
if (!xmlFile.open(QFile::WriteOnly | QFile::Text)) {
|
||
if(DBG) qDebug() << "SaveProject: Не удалось открыть файл "+projectPath + "/" + item->fileName;
|
||
return;
|
||
}
|
||
|
||
QTextStream outFile(&xmlFile);
|
||
item->doc.save(outFile, 4);
|
||
xmlFile.close();
|
||
//qDebug() << "Save ("+item->fileCode+"): " + projectPath + "/" + item->fileName;
|
||
|
||
if(item->moduleType == mtPM) continue;
|
||
|
||
if(item->html.count() > 0) {
|
||
QString htmlFileName = projectPath + "/" + QString(item->fileName).replace(".xml", ".html");
|
||
QFile htmlFile(htmlFileName);
|
||
if (htmlFile.open(QFile::ReadWrite | QFile::Text)) {
|
||
QTextStream out(&htmlFile); out.setCodec("UTF-8");
|
||
for(int i=0;i<item->html.count();i++)
|
||
out << QString(item->html[i]+"\n").toUtf8();
|
||
htmlFile.close();
|
||
}
|
||
}
|
||
|
||
QString lyxLogFileName = projectPath + "/" + item->fileName+"_importlog.txt"; //lyxLogFileName.toStdString()
|
||
QFile logFile(lyxLogFileName);
|
||
if (logFile.open(QFile::ReadWrite | QFile::Text)) {
|
||
QTextStream out(&logFile); out.setCodec("UTF-8");
|
||
for(int i=0;i<item->lyxLog.count();i++)
|
||
out << QString(item->lyxLog[i]+"\n").toUtf8();
|
||
logFile.close();
|
||
}
|
||
}
|
||
|
||
SavePackagesXML();
|
||
qSetGlobalQHashSeed(-1); // reset hash value
|
||
}
|
||
|
||
void S1000D_Manager::setCurItem(int ind) {
|
||
item = &items[ind]; itemIndex = ind;
|
||
}
|
||
|
||
void S1000D_Manager::replaceCurItem_pmCode(QString new_pmTitle, QString new_modelIdentCode, QString new_pmIssuer, QString new_pmNumber, QString new_pmVolume) {
|
||
ItemStruct *oldItem = item;
|
||
QString pmTitle, modelIdentCode, pmIssuer, pmNumber, pmVolume;
|
||
QString oldPMCodeStr, pmRefCodeStr;
|
||
pmTitle = getNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle");
|
||
modelIdentCode = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode");
|
||
pmIssuer = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer");
|
||
pmNumber = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmNumber");
|
||
pmVolume = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmVolume");
|
||
oldPMCodeStr = pmIdentString("identAndStatusSection.pmAddress.pmIdent");
|
||
|
||
setNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle", new_pmTitle);
|
||
setNodeText("content.pmEntry.pmEntryTitle", new_pmTitle);
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode", new_modelIdentCode);
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer", new_pmIssuer);
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmNumber", new_pmNumber);
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmVolume", new_pmVolume);
|
||
if(isNodeCreated("identAndStatusSection.pmAddress.pmAddressItems.shortPmTitle"))
|
||
deleteNode("identAndStatusSection.pmAddress.pmAddressItems.shortPmTitle");
|
||
|
||
if(item->parent != -1) {
|
||
int parent = item->parent;
|
||
setCurItem(parent);
|
||
int cntRef = getNodeChildsWithNameCount("content.pmEntry", "pmRef");
|
||
for(int p=0;p<cntRef;p++) { // цикл по pmRef
|
||
if(isNodeCreated("content.pmEntry.pmRef["+QString::number(p)+"].pmRefIdent")) {
|
||
pmRefCodeStr = pmIdentString("content.pmEntry.pmRef["+QString::number(p)+"].pmRefIdent");
|
||
//if(DBG) qDebug() << " replace PM - pmRef: " << PMCodeStr;
|
||
if(oldPMCodeStr.compare(pmRefCodeStr, Qt::CaseInsensitive) == 0) {
|
||
setNodeText("content.pmEntry.pmRef["+QString::number(p)+"].pmRefAddressItems.pmTitle", new_pmTitle);
|
||
setNodeAttr("content.pmEntry.pmRef["+QString::number(p)+"].pmRefIdent.pmCode", "modelIdentCode", new_modelIdentCode);
|
||
setNodeAttr("content.pmEntry.pmRef["+QString::number(p)+"].pmRefIdent.pmCode", "pmIssuer", new_pmIssuer);
|
||
setNodeAttr("content.pmEntry.pmRef["+QString::number(p)+"].pmRefIdent.pmCode", "pmNumber", new_pmNumber);
|
||
setNodeAttr("content.pmEntry.pmRef["+QString::number(p)+"].pmRefIdent.pmCode", "pmVolume", new_pmVolume);
|
||
}
|
||
}
|
||
} // pmRef
|
||
}
|
||
|
||
item = oldItem;
|
||
}
|
||
|
||
void S1000D_Manager::moveItemToPM(int itemInd, int pmInd, int pmContextEntryIndex) { //
|
||
ItemStruct *oldItem = item;
|
||
//QString refCodeStr;
|
||
//QDomNode oldItemNodeRef, cloneItemNodeRef;
|
||
//oldItemNodeRef.clear();
|
||
|
||
/*if(items[itemInd].parent != -1) {
|
||
for(int i=0;i<items.count();i++)
|
||
if(items[i].moduleType == mtPM) { // ищем старое место входа item в PM
|
||
setCurItem(i);
|
||
int cntRef = getNodeChildsWithNameCount("content.pmEntry", "pmRef");
|
||
for(int p=0;p<cntRef;p++) // цикл по pmRef
|
||
if(isNodeCreated("content.pmEntry.pmRef["+QString::number(p)+"].pmRefIdent")) {
|
||
refCodeStr = pmIdentString("content.pmEntry.pmRef["+QString::number(p)+"].pmRefIdent");
|
||
//if(DBG) qDebug() << " pmRef:" << items[itemInd].fileCode << "==?" << refCodeStr;
|
||
if(items[itemInd].fileCode.compare(refCodeStr, Qt::CaseInsensitive) == 0)
|
||
oldItemNodeRef = findElement("content.pmEntry.pmRef["+QString::number(p)+"]");
|
||
}
|
||
cntRef = getNodeChildsWithNameCount("content.pmEntry", "dmRef");
|
||
for(int p=0;p<cntRef;p++) // цикл по dmRef
|
||
if(isNodeCreated("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent")) {
|
||
refCodeStr = dmIdentString("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent");
|
||
//if(DBG) qDebug() << " dmRef:" << items[itemInd].fileCode << "==?" << refCodeStr;
|
||
if(items[itemInd].fileCode.compare(refCodeStr, Qt::CaseInsensitive) == 0)
|
||
oldItemNodeRef = findElement("content.pmEntry.dmRef["+QString::number(p)+"]");
|
||
}
|
||
if(!oldItemNodeRef.isNull()) break;
|
||
}
|
||
if(oldItemNodeRef.isNull()) {
|
||
if(DBG) qDebug() << " Error: cant find old PM - itemInd=" << itemInd << " is PM?" << (items[itemInd].moduleType==mtPM) << " items[itemInd].parent=" << items[itemInd].parent;
|
||
return; // как не нашли?
|
||
}
|
||
cloneItemNodeRef = oldItemNodeRef.cloneNode();
|
||
oldItemNodeRef.parentNode().removeChild(oldItemNodeRef);
|
||
setCurItem(pmInd);
|
||
QDomNode entry = findElement("content.pmEntry");
|
||
if(entry.childNodes().at(0).nodeName() == "pmEntryTitle")
|
||
entry.insertAfter(cloneItemNodeRef, entry.childNodes().at(pmContextEntryIndex));
|
||
else
|
||
entry.insertBefore(cloneItemNodeRef, entry.childNodes().at(pmContextEntryIndex));
|
||
}
|
||
else { // родителя ранее не было, создаем pmRef | dmRef
|
||
*/
|
||
if(items[itemInd].moduleType == mtPM) {
|
||
setCurItem(itemInd);
|
||
QString modelIdentCode = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode");
|
||
QString pmIssuer = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer");
|
||
QString pmNumber = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmNumber");
|
||
QString pmVolume = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmVolume");
|
||
QString issueNumber = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.issueInfo", "issueNumber");
|
||
QString inWork = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.issueInfo", "inWork");
|
||
QString languageIsoCode = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.language", "languageIsoCode");
|
||
QString countryIsoCode = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.language", "countryIsoCode");
|
||
QString pmTitle = getNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle");
|
||
|
||
setCurItem(pmInd);
|
||
QDomNode entry = findElement("content.pmEntry");
|
||
QDomElement pmRef = createEmpty_pmRef(modelIdentCode, pmIssuer);
|
||
entry.appendChild(pmRef);
|
||
QString newPMDOMIndexStr = QString::number(getNodeChildsWithNameCount("content.pmEntry", "pmRef")-1);
|
||
setNodeAttr("content.pmEntry.pmRef["+newPMDOMIndexStr+"].pmRefIdent.pmCode", "modelIdentCode", modelIdentCode);
|
||
setNodeAttr("content.pmEntry.pmRef["+newPMDOMIndexStr+"].pmRefIdent.pmCode", "pmIssuer", pmIssuer);
|
||
setNodeAttr("content.pmEntry.pmRef["+newPMDOMIndexStr+"].pmRefIdent.pmCode", "pmNumber", pmNumber);
|
||
setNodeAttr("content.pmEntry.pmRef["+newPMDOMIndexStr+"].pmRefIdent.pmCode", "pmVolume", pmVolume);
|
||
setNodeAttr("content.pmEntry.pmRef["+newPMDOMIndexStr+"].pmRefIdent.issueInfo", "issueNumber", issueNumber);
|
||
setNodeAttr("content.pmEntry.pmRef["+newPMDOMIndexStr+"].pmRefIdent.issueInfo", "inWork", inWork);
|
||
setNodeAttr("content.pmEntry.pmRef["+newPMDOMIndexStr+"].pmRefIdent.language", "languageIsoCode", languageIsoCode);
|
||
setNodeAttr("content.pmEntry.pmRef["+newPMDOMIndexStr+"].pmRefIdent.language", "countryIsoCode", countryIsoCode);
|
||
setNodeText("content.pmEntry.pmRef["+newPMDOMIndexStr+"].pmRefAddressItems.pmTitle", pmTitle);
|
||
}
|
||
|
||
if(items[itemInd].moduleType == mtDM) {
|
||
setCurItem(itemInd);
|
||
QString modelIdentCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode");
|
||
QString systemDiffCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemDiffCode");
|
||
QString systemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemCode");
|
||
QString subSystemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSystemCode");
|
||
QString subSubSystemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSubSystemCode");
|
||
QString assyCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "assyCode");
|
||
QString disassyCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCode");
|
||
QString disassyCodeVariant = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCodeVariant");
|
||
QString infoCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCode");
|
||
QString infoCodeVariant = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCodeVariant");
|
||
QString itemLocationCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "itemLocationCode");
|
||
QString learnCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnCode");
|
||
QString learnEventCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnEventCode");
|
||
QString techName = getNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName");
|
||
QString infoName = getNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.infoName");
|
||
QString issueNumber = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.issueInfo", "issueNumber");
|
||
QString inWork = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.issueInfo", "inWork");
|
||
QString languageIsoCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.language", "languageIsoCode");
|
||
QString countryIsoCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.language", "countryIsoCode");
|
||
|
||
setCurItem(pmInd);
|
||
QDomNode entry = findElement("content.pmEntry");
|
||
QDomElement dmRef = createEmpty_dmRef(modelIdentCode);
|
||
entry.appendChild(dmRef);
|
||
QString newDMDOMIndexStr = QString::number(getNodeChildsWithNameCount("content.pmEntry", "dmRef")-1);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.dmCode", "modelIdentCode", modelIdentCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.dmCode", "systemDiffCode", systemDiffCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.dmCode", "systemCode", systemCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.dmCode", "subSystemCode", subSystemCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.dmCode", "subSubSystemCode", subSubSystemCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.dmCode", "assyCode", assyCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.dmCode", "disassyCode", disassyCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.dmCode", "disassyCodeVariant", disassyCodeVariant);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.dmCode", "infoCode", infoCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.dmCode", "infoCodeVariant", infoCodeVariant);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.dmCode", "itemLocationCode", itemLocationCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.dmCode", "learnCode", learnCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.dmCode", "learnEventCode", learnEventCode);
|
||
setNodeText("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefAddressItems.dmTitle.techName", techName);
|
||
setNodeText("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefAddressItems.dmTitle.infoName", infoName);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.issueInfo", "issueNumber", issueNumber);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.issueInfo", "inWork", inWork);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.language", "languageIsoCode", languageIsoCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+newDMDOMIndexStr+"].dmRefIdent.language", "countryIsoCode", countryIsoCode);
|
||
}
|
||
//}
|
||
|
||
item = oldItem;
|
||
}
|
||
|
||
int S1000D_Manager::createPM(int parentItemInd, int insertAfterChildNum) {
|
||
int parent = parentItemInd;
|
||
while(true) {
|
||
if(parent == -1) break;
|
||
if(items[parent].moduleType == mtPM) break;
|
||
parent = items[parent].parent;
|
||
}
|
||
ItemStruct newPM;
|
||
newPM.parent = parent; newPM.child.clear();
|
||
newPM.moduleType = mtPM; newPM.schemeType = stPM;
|
||
newPM.isReady = false;
|
||
newPM.fileCode = ""; newPM.fileName = projectPath+"/"+"newfile"+QString::number(rand())+".xml";
|
||
newPM.importedFromLyX = ""; newPM.html.clear();
|
||
newPM.isQualifyed = true; //newPM.crewFlags = 0xFFFF;
|
||
|
||
QFile xmlFile(":new/BlankXML/pm.xml");
|
||
if (!xmlFile.open(QFile::ReadOnly | QFile::Text)) {
|
||
if(DBG) qDebug() << " Cant open :new/BlankXML/pm.xml";
|
||
return -1;
|
||
}
|
||
QByteArray fileData = xmlFile.readAll();
|
||
xmlFile.close();
|
||
|
||
newPM.doc.setContent(fileData);
|
||
items.append(newPM);
|
||
if(parent != -1)
|
||
items[parent].child.insert(insertAfterChildNum+1, items.count()-1);
|
||
setCurItem(items.count()-1);
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.issueInfo", "issueNumber", ru_const.issueNumber);
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.issueInfo", "inWork", ru_const.inWork);
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.language", "languageIsoCode", ru_const.languageIsoCode);
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.language", "countryIsoCode", ru_const.countryIsoCode);
|
||
setNodeAttr("identAndStatusSection.pmStatus.security", "securityClassification", ru_const.security_securityClassification);
|
||
setNodeText("identAndStatusSection.pmStatus.dataRestrictions.restrictionInfo.copyright.copyrightPara", ru_const.copyrightPara);
|
||
setNodeAttr("identAndStatusSection.pmStatus.responsiblePartnerCompany", "enterpriseCode", ru_const.responsiblePartnerCompany_enterpriseCode);
|
||
setNodeText("identAndStatusSection.pmStatus.responsiblePartnerCompany.enterpriseName", ru_const.responsiblePartnerCompany_enterpriseName);
|
||
setNodeAttr("identAndStatusSection.pmStatus.originator", "enterpriseCode", ru_const.originator_enterpriseCode);
|
||
setNodeText("identAndStatusSection.pmStatus.originator.enterpriseName", ru_const.originator_enterpriseName);
|
||
|
||
if(parent != -1) {
|
||
setCurItem(parent);
|
||
QString parent_modelIdentCode = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode");
|
||
QString parent_pmIssuer = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer");
|
||
QDomNode pmEntry = findElement("content.pmEntry");
|
||
QDomElement pmRef = createEmpty_pmRef(parent_modelIdentCode, parent_pmIssuer);
|
||
|
||
if(insertAfterChildNum >= pmEntry.childNodes().count()) {
|
||
if(DBG) qDebug() << " Error: createPM - insertAfterChildNum >= pmEntry.childNodes().count()";
|
||
return items.count()-1;
|
||
}
|
||
if(isNodeCreated("content.pmEntry.pmEntryTitle"))
|
||
pmEntry.insertAfter(pmRef, pmEntry.childNodes().at(insertAfterChildNum+1));
|
||
else
|
||
pmEntry.insertAfter(pmRef, pmEntry.childNodes().at(insertAfterChildNum));
|
||
|
||
setCurItem(items.count()-1);
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode", parent_modelIdentCode);
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer", parent_pmIssuer);
|
||
}
|
||
|
||
prepareSaveProject();
|
||
return items.count()-1;
|
||
}
|
||
|
||
int S1000D_Manager::createDM(int parentItemInd, int insertAfterChildNum, QString scheme) {
|
||
int parent = parentItemInd;
|
||
while(true) {
|
||
if(parent == -1) break;
|
||
if(items[parent].moduleType == mtPM) break;
|
||
parent = items[parent].parent;
|
||
}
|
||
ItemStruct newDM;
|
||
newDM.parent = parent; newDM.child.clear();
|
||
newDM.moduleType = mtDM; newDM.schemeType = getSchemeTypeByStr(scheme);
|
||
newDM.isReady = false;
|
||
newDM.fileCode = ""; newDM.fileName = projectPath+"/"+"~NEWFILE"+QString::number(rand())+".xml";
|
||
newDM.importedFromLyX = ""; newDM.html.clear();
|
||
newDM.isQualifyed = true; //newDM.crewFlags = 0xFFFF;
|
||
|
||
QFile xmlFile(":new/BlankXML/"+scheme.toLower()+".xml");
|
||
if (!xmlFile.open(QFile::ReadOnly | QFile::Text)) {
|
||
if(DBG) qDebug() << " Cant open :new/BlankXML/"+scheme.toLower()+".xml";
|
||
return -1;
|
||
}
|
||
QByteArray fileData = xmlFile.readAll();
|
||
xmlFile.close();
|
||
|
||
newDM.doc.setContent(fileData);
|
||
items.append(newDM);
|
||
if(parent != -1)
|
||
items[parent].child.insert(insertAfterChildNum+1, items.count()-1);
|
||
setCurItem(items.count()-1);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.issueInfo", "issueNumber", ru_const.issueNumber);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.issueInfo", "inWork", ru_const.inWork);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.language", "languageIsoCode", ru_const.languageIsoCode);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.language", "countryIsoCode", ru_const.countryIsoCode);
|
||
setNodeAttr("identAndStatusSection.dmStatus.security", "securityClassification", ru_const.security_securityClassification);
|
||
setNodeAttr("identAndStatusSection.dmStatus.responsiblePartnerCompany", "enterpriseCode", ru_const.responsiblePartnerCompany_enterpriseCode);
|
||
setNodeText("identAndStatusSection.dmStatus.responsiblePartnerCompany.enterpriseName", ru_const.responsiblePartnerCompany_enterpriseName);
|
||
setNodeAttr("identAndStatusSection.dmStatus.originator", "enterpriseCode", ru_const.originator_enterpriseCode);
|
||
setNodeText("identAndStatusSection.dmStatus.originator.enterpriseName", ru_const.originator_enterpriseName);
|
||
|
||
if(parent != -1) {
|
||
setCurItem(parent);
|
||
QString parent_modelIdentCode = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode");
|
||
//QString parent_pmIssuer = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer");
|
||
QDomNode pmEntry = findElement("content.pmEntry");
|
||
QDomElement dmRef = createEmpty_dmRef(parent_modelIdentCode);
|
||
|
||
if(insertAfterChildNum >= pmEntry.childNodes().count()) {
|
||
if(DBG) qDebug() << " Error: createDM - insertAfterChildNum >= pmEntry.childNodes().count()";
|
||
return items.count()-1;
|
||
}
|
||
if(isNodeCreated("content.pmEntry.pmEntryTitle"))
|
||
pmEntry.insertAfter(dmRef, pmEntry.childNodes().at(insertAfterChildNum+1));
|
||
else
|
||
pmEntry.insertAfter(dmRef, pmEntry.childNodes().at(insertAfterChildNum));
|
||
|
||
setCurItem(items.count()-1);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode", parent_modelIdentCode);
|
||
}
|
||
setNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName", "Задайте имя и кодирование модуля");
|
||
|
||
prepareSaveProject();
|
||
return items.count()-1;
|
||
}
|
||
|
||
QDomElement S1000D_Manager::createEmpty_pmRef(QString parent_modelIdentCode, QString parent_pmIssuer) {
|
||
QDomElement pmRef = item->doc.createElement("pmRef");
|
||
QDomElement pmRefIdent = item->doc.createElement("pmRefIdent");
|
||
pmRef.appendChild(pmRefIdent);
|
||
QDomElement pmCode = item->doc.createElement("pmCode");
|
||
pmRefIdent.appendChild(pmCode);
|
||
pmCode.setAttribute("modelIdentCode", parent_modelIdentCode);
|
||
pmCode.setAttribute("pmIssuer", parent_pmIssuer);
|
||
pmCode.setAttribute("pmNumber", "");
|
||
pmCode.setAttribute("pmVolume", "");
|
||
QDomElement issueInfo = item->doc.createElement("issueInfo");
|
||
pmRefIdent.appendChild(issueInfo);
|
||
issueInfo.setAttribute("inWork", ru_const.inWork);
|
||
issueInfo.setAttribute("issueNumber", ru_const.issueNumber);
|
||
QDomElement language = item->doc.createElement("language");
|
||
pmRefIdent.appendChild(language);
|
||
language.setAttribute("languageIsoCode", ru_const.languageIsoCode);
|
||
language.setAttribute("countryIsoCode", ru_const.countryIsoCode);
|
||
|
||
QDomElement pmRefAddressItems = item->doc.createElement("pmRefAddressItems");
|
||
pmRef.appendChild(pmRefAddressItems);
|
||
QDomElement pmTitle = item->doc.createElement("pmTitle");
|
||
pmRefAddressItems.appendChild(pmTitle);
|
||
pmTitle.appendChild(item->doc.createTextNode(""));
|
||
QDomElement issueDate = item->doc.createElement("issueDate");
|
||
pmRefAddressItems.appendChild(issueDate);
|
||
issueDate.setAttribute("day", "");
|
||
issueDate.setAttribute("month", "");
|
||
issueDate.setAttribute("year", "");
|
||
return pmRef;
|
||
}
|
||
|
||
QDomElement S1000D_Manager::createEmpty_dmRef(QString parent_modelIdentCode) {
|
||
QDomElement dmRef = item->doc.createElement("dmRef");
|
||
QDomElement dmRefIdent = item->doc.createElement("dmRefIdent");
|
||
dmRef.appendChild(dmRefIdent);
|
||
QDomElement dmCode = item->doc.createElement("dmCode");
|
||
dmRefIdent.appendChild(dmCode);
|
||
dmCode.setAttribute("modelIdentCode", parent_modelIdentCode);
|
||
dmCode.setAttribute("systemDiffCode", "");
|
||
dmCode.setAttribute("systemCode", "");
|
||
dmCode.setAttribute("subSystemCode", "");
|
||
dmCode.setAttribute("subSubSystemCode", "");
|
||
dmCode.setAttribute("assyCode", "");
|
||
dmCode.setAttribute("disassyCode", "");
|
||
dmCode.setAttribute("disassyCodeVariant", "");
|
||
dmCode.setAttribute("infoCode", "");
|
||
dmCode.setAttribute("infoCodeVariant", "");
|
||
dmCode.setAttribute("itemLocationCode", "");
|
||
dmCode.setAttribute("learnCode", "");
|
||
dmCode.setAttribute("learnEventCode", "");
|
||
QDomElement issueInfo = item->doc.createElement("issueInfo");
|
||
dmRefIdent.appendChild(issueInfo);
|
||
issueInfo.setAttribute("inWork", ru_const.inWork);
|
||
issueInfo.setAttribute("issueNumber", ru_const.issueNumber);
|
||
QDomElement language = item->doc.createElement("language");
|
||
dmRefIdent.appendChild(language);
|
||
language.setAttribute("languageIsoCode", ru_const.languageIsoCode);
|
||
language.setAttribute("countryIsoCode", ru_const.countryIsoCode);
|
||
|
||
QDomElement dmRefAddressItems = item->doc.createElement("dmRefAddressItems");
|
||
dmRef.appendChild(dmRefAddressItems);
|
||
QDomElement dmTitle = item->doc.createElement("dmTitle");
|
||
dmRefAddressItems.appendChild(dmTitle);
|
||
QDomElement dmTechName = item->doc.createElement("techName");
|
||
dmTitle.appendChild(dmTechName);
|
||
dmTechName.appendChild(item->doc.createTextNode(""));
|
||
QDomElement dmInfoName = item->doc.createElement("infoName");
|
||
dmTitle.appendChild(dmInfoName);
|
||
dmInfoName.appendChild(item->doc.createTextNode(""));
|
||
QDomElement issueDate = item->doc.createElement("issueDate");
|
||
dmRefAddressItems.appendChild(issueDate);
|
||
issueDate.setAttribute("day", "");
|
||
issueDate.setAttribute("month", "");
|
||
issueDate.setAttribute("year", "");
|
||
return dmRef;
|
||
}
|
||
|
||
void S1000D_Manager::deleteItem(int itemInd) {
|
||
prepareSaveProject();
|
||
QDomNode oldItemNodeRef;
|
||
int itemParent = items[itemInd].parent;
|
||
QString fileName = items[itemInd].fileName;
|
||
|
||
if(items[itemInd].child.count() > 0) return;
|
||
if(itemParent != -1) {
|
||
QString refCodeStr = "";
|
||
setCurItem(itemParent);
|
||
int cntRef = getNodeChildsWithNameCount("content.pmEntry", "pmRef");
|
||
for(int p=0;p<cntRef;p++) // цикл по pmRef
|
||
if(isNodeCreated("content.pmEntry.pmRef["+QString::number(p)+"].pmRefIdent")) {
|
||
refCodeStr = pmIdentString("content.pmEntry.pmRef["+QString::number(p)+"].pmRefIdent");
|
||
//if(DBG) qDebug() << " " << items[itemInd].fileCode << "==?" << refCodeStr;
|
||
if(items[itemInd].fileCode.compare(refCodeStr, Qt::CaseInsensitive) == 0)
|
||
oldItemNodeRef = findElement("content.pmEntry.pmRef["+QString::number(p)+"]");
|
||
}
|
||
cntRef = getNodeChildsWithNameCount("content.pmEntry", "dmRef");
|
||
for(int p=0;p<cntRef;p++) // цикл по dmRef
|
||
if(isNodeCreated("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent")) {
|
||
refCodeStr = dmIdentString("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent");
|
||
if(items[itemInd].fileCode.compare(refCodeStr, Qt::CaseInsensitive) == 0)
|
||
oldItemNodeRef = findElement("content.pmEntry.dmRef["+QString::number(p)+"]");
|
||
}
|
||
if(oldItemNodeRef.isNull()) {
|
||
if(DBG) qDebug() << " Error: deleteItem - oldItemNodeRef not found";
|
||
return;
|
||
}
|
||
|
||
oldItemNodeRef.parentNode().removeChild(oldItemNodeRef);
|
||
}
|
||
|
||
if(itemParent != -1) {
|
||
if(items[itemParent].child.indexOf(itemInd) == -1) if(DBG) qDebug() << " Error: deleteItem - indexOf(itemInd) == -1" << items[itemParent].child.indexOf(itemInd) << items[itemParent].child.count();
|
||
items[itemParent].child.removeAt( items[itemParent].child.indexOf(itemInd) );
|
||
}
|
||
items.removeAt(itemInd);
|
||
for(int i=0;i<items.count();i++)
|
||
for(int j=0;j<items[i].child.count();j++) {
|
||
if(items[i].child[j] == itemInd) if(DBG) qDebug() << " Error: deleteItem - dublicate of itemInd found";
|
||
if(items[i].child[j] > itemInd) items[i].child[j]--;
|
||
}
|
||
|
||
QFile itemFile(fileName);
|
||
if(QFileInfo::exists(fileName)) {
|
||
itemFile.setPermissions(QFileDevice::WriteUser | QFileDevice::ReadUser | QFileDevice::ExeUser);
|
||
itemFile.remove();
|
||
}
|
||
}
|
||
|
||
void S1000D_Manager::replaceCurItem_dmCode(QString new_techName, QString new_infoName,
|
||
QString new_modelIdentCode, QString new_systemDiffCode,
|
||
QString new_systemCode, QString new_subSystemCode, QString new_subSubSystemCode, QString new_assyCode,
|
||
QString new_disassyCode, QString new_disassyCodeVariant,
|
||
QString new_infoCode, QString new_infoCodeVariant,
|
||
QString new_itemLocationCode, QString new_learnCode, QString new_learnEventCode) {
|
||
if(item->moduleType != mtDM) return;
|
||
|
||
ItemStruct *oldItem = item;
|
||
QString oldDMCodeStr, dmRefCodeStr;
|
||
|
||
oldDMCodeStr = dmIdentString("identAndStatusSection.dmAddress.dmIdent");
|
||
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode", new_modelIdentCode);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemDiffCode", new_systemDiffCode);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemCode", new_systemCode);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSystemCode", new_subSystemCode);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSubSystemCode", new_subSubSystemCode);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "assyCode", new_assyCode);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCode", new_disassyCode);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCodeVariant", new_disassyCodeVariant);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCode", new_infoCode);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCodeVariant", new_infoCodeVariant);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "itemLocationCode", new_itemLocationCode);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnCode", new_learnCode);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnEventCode", new_learnEventCode);
|
||
setNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName", new_techName);
|
||
setNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.infoName", new_infoName);
|
||
if(item->schemeType == stLEARNING)
|
||
setNodeText("content.learning.learningAssessment.title", new_techName +" - "+ new_infoName);
|
||
|
||
if(item->parent != -1) {
|
||
int parent = item->parent;
|
||
setCurItem(parent);
|
||
int cntRef = getNodeChildsWithNameCount("content.pmEntry", "dmRef");
|
||
for(int p=0;p<cntRef;p++) { // цикл по dmRef
|
||
if(isNodeCreated("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent")) {
|
||
dmRefCodeStr = dmIdentString("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent");
|
||
//if(DBG) qDebug() << " replace DM - dmRef: " << DMCodeStr;
|
||
if(oldDMCodeStr.compare(dmRefCodeStr, Qt::CaseInsensitive) == 0) {
|
||
setNodeAttr("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent.dmCode", "modelIdentCode", new_modelIdentCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent.dmCode", "systemDiffCode", new_systemDiffCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent.dmCode", "systemCode", new_systemCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent.dmCode", "subSystemCode", new_subSystemCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent.dmCode", "subSubSystemCode", new_subSubSystemCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent.dmCode", "assyCode", new_assyCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent.dmCode", "disassyCode", new_disassyCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent.dmCode", "disassyCodeVariant", new_disassyCodeVariant);
|
||
setNodeAttr("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent.dmCode", "infoCode", new_infoCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent.dmCode", "infoCodeVariant", new_infoCodeVariant);
|
||
setNodeAttr("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent.dmCode", "itemLocationCode", new_itemLocationCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent.dmCode", "learnCode", new_learnCode);
|
||
setNodeAttr("content.pmEntry.dmRef["+QString::number(p)+"].dmRefIdent.dmCode", "learnEventCode", new_learnEventCode);
|
||
setNodeText("content.pmEntry.dmRef["+QString::number(p)+"].dmRefAddressItems.dmTitle.techName", new_techName);
|
||
setNodeText("content.pmEntry.dmRef["+QString::number(p)+"].dmRefAddressItems.dmTitle.infoName", new_infoName);
|
||
}
|
||
}
|
||
} // dmRef
|
||
}
|
||
|
||
item = oldItem;
|
||
}
|
||
|
||
void S1000D_Manager::resetICN() {
|
||
ICN_UI = 0;
|
||
}
|
||
|
||
QString S1000D_Manager::genICN() {
|
||
if(item->moduleType == mtPM) return "ICN-ERROR-PM";
|
||
QString modelIdentCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode");
|
||
QString systemDiffCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemDiffCode");
|
||
QString systemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemCode");
|
||
QString subSystemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSystemCode");
|
||
QString subSubSystemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSubSystemCode");
|
||
QString issueNumber = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.issueInfo", "issueNumber");
|
||
QString z; z.fill('0',5-QString::number(ICN_UI).length());
|
||
QString icn_ui = z + QString::number(ICN_UI);
|
||
ICN_UI++;
|
||
QString icn = "ICN-"+modelIdentCode+"-"+systemDiffCode+"-"+systemCode+subSystemCode+subSubSystemCode+"-A-"+
|
||
ru_const.originator_enterpriseCode+"-"+icn_ui+"-"+ru_const.icn_variantCode+"-"+issueNumber+"-1";
|
||
return icn;
|
||
}
|
||
|
||
bool S1000D_Manager::copyDir(const QString &srcPath, const QString &dstPath)
|
||
{
|
||
QDir dstdir = QDir(dstPath);
|
||
//if (dstdir.exists()) dstdir.removeRecursively(); // не удаляем существующую
|
||
// QDir parentDstDir(QFileInfo(dstPath).path());
|
||
if (!dstdir.exists())
|
||
{
|
||
// if (!parentDstDir.mkdir(QFileInfo(dstPath).fileName()))
|
||
if (!dstdir.mkpath(dstPath))
|
||
return false;
|
||
}
|
||
|
||
QDir srcDir(srcPath);
|
||
foreach(const QFileInfo &info, srcDir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) {
|
||
QString srcItemPath = srcPath + "/" + info.fileName();
|
||
QString dstItemPath = dstPath + "/" + info.fileName();
|
||
if (info.isDir()) {
|
||
if (!copyDir(srcItemPath, dstItemPath))
|
||
return false;
|
||
} else if (info.isFile()) {
|
||
if(!QFileInfo(dstItemPath).exists())
|
||
if (!QFile::copy(srcItemPath, dstItemPath))
|
||
return false;
|
||
} else {
|
||
qDebug() << "Unhandled item in copyDir: " + info.filePath();
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
void S1000D_Manager::ParsePackageContent(QDomNode node, int parentItem) {
|
||
for(int i=0;i<node.childNodes().count();i++)
|
||
for(int j=0;j<items.count();j++)
|
||
if(items[j].parent == parentItem)
|
||
if((node.childNodes().at(i).nodeName() == "PM" && items[j].moduleType == mtPM) ||
|
||
(node.childNodes().at(i).nodeName() == "DM" && items[j].moduleType == mtDM))
|
||
{
|
||
setCurItem(j);
|
||
QString title;
|
||
if(item->moduleType == mtDM)
|
||
title = getNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName");
|
||
else
|
||
title = getNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle");
|
||
QString nodeName = node.childNodes().at(i).toElement().attribute("name");
|
||
QString nodeOrigTitle = node.childNodes().at(i).toElement().attribute("origTitle");
|
||
if(nodeOrigTitle == "") nodeOrigTitle = nodeName;
|
||
|
||
if(nodeOrigTitle != item->origTitle)
|
||
continue;
|
||
if(nodeName != nodeOrigTitle && nodeName != "") {
|
||
if(item->moduleType == mtDM)
|
||
setNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName", nodeName);
|
||
else
|
||
setNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle", nodeName);
|
||
} else {
|
||
if(item->moduleType == mtDM)
|
||
setNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName", nodeOrigTitle);
|
||
else
|
||
setNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle", nodeOrigTitle);
|
||
}
|
||
|
||
QString t = node.childNodes().at(i).toElement().attribute("packs");
|
||
|
||
QStringList packNames = node.childNodes().at(i).toElement().attribute("packs").split(",");
|
||
foreach(PackageStruct pck, packages)
|
||
if(pck.cfgName != "" && packNames.contains(pck.cfgName))
|
||
if(!item->inPackages.contains(pck.cfgName))
|
||
item->inPackages.append(pck.cfgName);
|
||
|
||
QString infoCode, learnCode, disassyCode, systemCode, subSubSystemCode, subSystemCode,
|
||
learnEventCode, itemLocationCode, systemDiffCode, modelIdentCode, infoCodeVariant, assyCode, disassyCodeVariant,
|
||
pmIssuer, pmNumber, pmVolume;
|
||
if(item->moduleType == mtDM) {
|
||
modelIdentCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode");
|
||
if(modelIdentCode == "") {
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCode", node.childNodes().at(i).toElement().attribute("infoCode"));
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnCode", node.childNodes().at(i).toElement().attribute("learnCode"));
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCode", node.childNodes().at(i).toElement().attribute("disassyCode"));
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemCode", node.childNodes().at(i).toElement().attribute("systemCode"));
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSubSystemCode", node.childNodes().at(i).toElement().attribute("subSubSystemCode"));
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSystemCode", node.childNodes().at(i).toElement().attribute("subSystemCode"));
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnEventCode", node.childNodes().at(i).toElement().attribute("learnEventCode"));
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "itemLocationCode", node.childNodes().at(i).toElement().attribute("itemLocationCode"));
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemDiffCode", node.childNodes().at(i).toElement().attribute("systemDiffCode"));
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode", node.childNodes().at(i).toElement().attribute("modelIdentCode"));
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCodeVariant", node.childNodes().at(i).toElement().attribute("infoCodeVariant"));
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "assyCode", node.childNodes().at(i).toElement().attribute("assyCode"));
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCodeVariant", node.childNodes().at(i).toElement().attribute("disassyCodeVariant"));
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.language", "languageIsoCode", ru_const.languageIsoCode);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.language", "countryIsoCode", ru_const.countryIsoCode);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.issueInfo", "inWork", ru_const.inWork);
|
||
setNodeAttr("identAndStatusSection.dmAddress.dmIdent.issueInfo", "issueNumber", ru_const.issueNumber);
|
||
item->isQualifyed = (node.childNodes().at(i).toElement().attribute("isQualifyed") == "1");
|
||
|
||
}
|
||
}
|
||
else {
|
||
modelIdentCode = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode");
|
||
if(modelIdentCode == "") {
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer", node.childNodes().at(i).toElement().attribute("pmIssuer"));
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmNumber", node.childNodes().at(i).toElement().attribute("pmNumber"));
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmVolume", node.childNodes().at(i).toElement().attribute("pmVolume"));
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode", node.childNodes().at(i).toElement().attribute("modelIdentCode"));
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.language", "languageIsoCode", ru_const.languageIsoCode);
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.language", "countryIsoCode", ru_const.countryIsoCode);
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.issueInfo", "inWork", ru_const.inWork);
|
||
setNodeAttr("identAndStatusSection.pmAddress.pmIdent.issueInfo", "issueNumber", ru_const.issueNumber);
|
||
item->isQualifyed = (node.childNodes().at(i).toElement().attribute("isQualifyed") == "1");
|
||
}
|
||
}
|
||
|
||
ParsePackageContent(node.childNodes().at(i), j);
|
||
}
|
||
}
|
||
|
||
void S1000D_Manager::LoadPackagesXML()
|
||
{
|
||
QDomDocument packDOM;
|
||
QString xmlFileName = rootLyXfile; xmlFileName.replace(".lyx", ".xml");
|
||
QFile packFile(xmlFileName); //QFileInfo(rootLyXfile).path()+"/packages.xml"
|
||
if (!packFile.open(QFile::ReadOnly | QFile::Text)) {
|
||
//if(DBG) qDebug() << "LoadPackagesXML: Не удалось открыть файл "+xmlFileName;
|
||
return;
|
||
}
|
||
packDOM.setContent(packFile.readAll());
|
||
packFile.close();
|
||
|
||
//QString lyxFileName = packDOM.namedItem("packages").namedItem("lyx").toElement().attribute("filename");
|
||
//if(lyxFileName != QFileInfo(rootLyXfile).fileName()) {
|
||
// qDebug() << "LoadPackagesXML: Ошибка импорта - имена исходных файлов LyX отличаются.";
|
||
// return;
|
||
//}
|
||
QDomNode packList = packDOM.namedItem("packages").namedItem("packlist");
|
||
QDomNode contents = packDOM.namedItem("packages").namedItem("contents");
|
||
timeConvert = packList.toElement().attribute("tConvert").toInt();
|
||
timeSCORM = packList.toElement().attribute("tSCORM").toInt();
|
||
timeS1000D = packList.toElement().attribute("tS1000D").toInt();
|
||
packages.clear();
|
||
for(int i=0;i<packList.childNodes().count();i++) {
|
||
PackageStruct pck;
|
||
pck.cfgName = packList.childNodes().at(i).toElement().attribute("name"); //QString(packList.childNodes().at(i).toElement().attribute("name").toLocal8Bit());
|
||
pck.title = packList.childNodes().at(i).toElement().attribute("title");
|
||
pck.exportFileName = packList.childNodes().at(i).toElement().attribute("file");
|
||
packages.append(pck);
|
||
}
|
||
ParsePackageContent(contents, -1);
|
||
}
|
||
|
||
void S1000D_Manager::AddPackageContent(QDomNode parent, int ind) {
|
||
QDomNode node;
|
||
setCurItem(ind);
|
||
|
||
QString title, infoCode, learnCode, disassyCode, systemCode, subSubSystemCode, subSystemCode,
|
||
learnEventCode, itemLocationCode, systemDiffCode, modelIdentCode, infoCodeVariant, assyCode, disassyCodeVariant,
|
||
pmIssuer, pmNumber, pmVolume;
|
||
if(item->moduleType == mtDM)
|
||
{
|
||
node = parent.ownerDocument().createElement("DM");
|
||
title = getNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName");
|
||
node.toElement().setAttribute("name", title);
|
||
|
||
infoCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCode"); node.toElement().setAttribute("infoCode", infoCode);
|
||
learnCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnCode"); node.toElement().setAttribute("learnCode", learnCode);
|
||
disassyCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCode"); node.toElement().setAttribute("disassyCode", disassyCode);
|
||
systemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemCode"); node.toElement().setAttribute("systemCode", systemCode);
|
||
subSubSystemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSubSystemCode"); node.toElement().setAttribute("subSubSystemCode", subSubSystemCode);
|
||
subSystemCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSystemCode"); node.toElement().setAttribute("subSystemCode", subSystemCode);
|
||
learnEventCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnEventCode"); node.toElement().setAttribute("learnEventCode", learnEventCode);
|
||
itemLocationCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "itemLocationCode"); node.toElement().setAttribute("itemLocationCode", itemLocationCode);
|
||
systemDiffCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemDiffCode"); node.toElement().setAttribute("systemDiffCode", systemDiffCode);
|
||
modelIdentCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode"); node.toElement().setAttribute("modelIdentCode", modelIdentCode);
|
||
infoCodeVariant = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCodeVariant"); node.toElement().setAttribute("infoCodeVariant", infoCodeVariant);
|
||
assyCode = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "assyCode"); node.toElement().setAttribute("assyCode", assyCode);
|
||
disassyCodeVariant = getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCodeVariant"); node.toElement().setAttribute("disassyCodeVariant", disassyCodeVariant);
|
||
node.toElement().setAttribute("isQualifyed", (int)item->isQualifyed);
|
||
node.toElement().setAttribute("origTitle", item->origTitle);
|
||
//infoCode="043" learnCode="T40" disassyCode="00" systemCode="05" subSubSystemCode="2" subSystemCode="6"
|
||
//learnEventCode="C" itemLocationCode="A" systemDiffCode="A" modelIdentCode="MI38" infoCodeVariant="A" assyCode="00" disassyCodeVariant="A"
|
||
}
|
||
else
|
||
{
|
||
node = parent.ownerDocument().createElement("PM");
|
||
title = getNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle");
|
||
node.toElement().setAttribute("name", title);
|
||
|
||
pmIssuer = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer"); node.toElement().setAttribute("pmIssuer", pmIssuer);
|
||
pmNumber = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmNumber"); node.toElement().setAttribute("pmNumber", pmNumber);
|
||
pmVolume = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmVolume"); node.toElement().setAttribute("pmVolume", pmVolume);
|
||
modelIdentCode = getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode"); node.toElement().setAttribute("modelIdentCode", modelIdentCode);
|
||
node.toElement().setAttribute("isQualifyed", (int)item->isQualifyed);
|
||
node.toElement().setAttribute("origTitle", item->origTitle);
|
||
//pmIssuer="RHC01" pmNumber="FTC01" pmVolume="00" modelIdentCode="MI38"
|
||
}
|
||
parent.appendChild(node);
|
||
QString liststr = item->inPackages.join(",");
|
||
node.toElement().setAttribute("packs", liststr);
|
||
|
||
for(int i=0;i<items[ind].child.count();i++)
|
||
AddPackageContent(node, items[ind].child[i]);
|
||
}
|
||
|
||
void S1000D_Manager::SavePackagesXML()
|
||
{
|
||
QDomDocument packDOM;
|
||
QFile blankFile(":new/BlankXML/packages.xml");
|
||
blankFile.open(QFile::ReadOnly | QFile::Text);
|
||
packDOM.setContent(blankFile.readAll());
|
||
blankFile.close();
|
||
|
||
QDomNode packList = packDOM.namedItem("packages").namedItem("packlist");
|
||
QDomNode contents = packDOM.namedItem("packages").namedItem("contents");
|
||
packList.toElement().setAttribute("tConvert", timeConvert);
|
||
packList.toElement().setAttribute("tSCORM", timeSCORM);
|
||
packList.toElement().setAttribute("tS1000D", timeS1000D);
|
||
//packDOM.namedItem("packages").namedItem("lyx").toElement().setAttribute("filename", QFileInfo(rootLyXfile).fileName());
|
||
foreach(PackageStruct pck, packages)
|
||
{
|
||
QDomNode packNode = packDOM.createElement("pack");
|
||
packList.appendChild(packNode);
|
||
packNode.toElement().setAttribute("name", pck.cfgName);
|
||
packNode.toElement().setAttribute("title", pck.title);
|
||
packNode.toElement().setAttribute("file", pck.exportFileName);
|
||
}
|
||
|
||
for(int i=0;i<items.count();i++)
|
||
if(items[i].parent == -1)
|
||
AddPackageContent(contents, i);
|
||
|
||
QString xmlFileName = rootLyXfile; xmlFileName.replace(".lyx", ".xml");
|
||
QFile packOutFile(xmlFileName); //QFileInfo(rootLyXfile).path()+"/packages.xml"
|
||
if (!packOutFile.open(QFile::WriteOnly | QFile::Text)) {
|
||
if(DBG) qDebug() << "SavePackagesXML: Не удалось записать файл "+xmlFileName;
|
||
return;
|
||
}
|
||
QTextStream outFile(&packOutFile);
|
||
packDOM.save(outFile, 4);
|
||
packOutFile.close();
|
||
}
|
||
|
||
|
||
// ------------------------------------------------ EXPORT --------------------------------------------------------
|
||
void S1000D_Manager::fillManifest(int ind, QDomNode curOrgNode, QDomNode resNode, QDomDocument manifest) {
|
||
if(!items[ind].toExport) return;
|
||
QDomNode itemNode = manifest.createElement("item");
|
||
curOrgNode.appendChild(itemNode);
|
||
|
||
int lvl=0, i=ind;
|
||
while(items[i].parent != -1) {
|
||
i = items[i].parent; lvl++;
|
||
}
|
||
|
||
if(items[ind].moduleType == mtPM) {
|
||
itemNode.toElement().setAttribute("identifier", "id_"+items[ind].fileCode);
|
||
itemNode.toElement().setAttribute("identifierref", items[ind].fileCode);
|
||
QDomNode titleNode = manifest.createElement("title");
|
||
itemNode.appendChild(titleNode);
|
||
QString title = items[ind].doc.namedItem("pm").namedItem("identAndStatusSection").namedItem("pmAddress").namedItem("pmAddressItems").namedItem("pmTitle").childNodes().at(0).nodeValue();
|
||
titleNode.appendChild(manifest.createTextNode(title));
|
||
|
||
int fontsize = 18; if(lvl > 0) fontsize = 16;
|
||
int padtop = 15; if(lvl > 0) padtop = 5;
|
||
addHTML(8+lvl*2, "<tr><td><div onclick=\"\" style=\"padding-left: "+QString::number((lvl*20))+"px;font-size: "+QString::number(fontsize)+"px;padding-top: "+QString::number(padtop)+"px;\";>▸ "+title+"</div></td></tr>");
|
||
|
||
for(int i=0;i<items[ind].child.count();i++)
|
||
fillManifest(items[ind].child[i], itemNode, resNode, manifest);
|
||
} else {
|
||
itemNode.toElement().setAttribute("identifier", "id_"+items[ind].fileCode);
|
||
itemNode.toElement().setAttribute("identifierref", items[ind].fileCode);
|
||
QDomNode titleNode = manifest.createElement("title");
|
||
itemNode.appendChild(titleNode);
|
||
QString title = items[ind].doc.namedItem("dmodule").namedItem("identAndStatusSection").namedItem("dmAddress").namedItem("dmAddressItems").namedItem("dmTitle").namedItem("techName").childNodes().at(0).nodeValue();
|
||
titleNode.appendChild(manifest.createTextNode(title));
|
||
|
||
QDomNode resource = manifest.createElement("resource");
|
||
resNode.appendChild(resource);
|
||
QString hrefStr = items[ind].SCORM_fileName.split("/").last();
|
||
resource.toElement().setAttribute("type", "webcontent");
|
||
resource.toElement().setAttribute("adlcp:scormType", "sco");
|
||
resource.toElement().setAttribute("identifier", items[ind].fileCode);
|
||
resource.toElement().setAttribute("href", hrefStr);
|
||
QDomNode file = manifest.createElement("file");
|
||
resource.appendChild(file);
|
||
file.toElement().setAttribute("href", hrefStr);
|
||
QDomNode dependency = manifest.createElement("dependency");
|
||
resource.appendChild(dependency);
|
||
dependency.toElement().setAttribute("identifierref", "SharedFiles");
|
||
|
||
addHTML(8+lvl*2, "<tr><td><div onclick=\"setContent('"+hrefStr+"');\" style=\"padding-left: "+QString::number((lvl*20))+"px;font-size: 16px;padding-top: 5px;\" onmouseover=\"document.body.style.cursor = 'pointer';\" onmouseout=\"document.body.style.cursor = 'auto';\">● "+title+"</div></td></tr>");
|
||
}
|
||
|
||
//<tr><td><div onclick="setContent('');" style="padding-left: 0px;font-size: 18px;padding-top: 5px;" onmouseover="document.body.style.cursor = 'pointer';" onmouseout="document.body.style.cursor = 'auto';">▸ 1 Общие сведения о вертолете</div></td></tr>
|
||
//<tr><td><div onclick="setContent('');" style="padding-left: 15px;font-size: 16px;padding-top: 5px;" onmouseover="document.body.style.cursor = 'pointer';" onmouseout="document.body.style.cursor = 'auto';">▸ 2 Фюзеляж вертолета</div></td></tr>
|
||
//<tr><td><div onclick="setContent('crew.xml');" style="padding-left: 35px;font-size: 16px;padding-top: 5px;" onmouseover="document.body.style.cursor = 'pointer';" onmouseout="document.body.style.cursor = 'auto';">● Компоненты фюзеляжа</div></td></tr>
|
||
}
|
||
|
||
void S1000D_Manager::addHTML(int lvl, QString s) {
|
||
QString spc = ""; for(int j=0;j<lvl;j++) spc += " ";
|
||
html.append(spc+s);
|
||
}
|
||
|
||
void S1000D_Manager::catHTML(QString s) {
|
||
html[html.count()-1] += s;
|
||
}
|
||
|
||
bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString packTitle, SplashForm* splash) {
|
||
// функция так же требует расставленных флагов items[i].toExport
|
||
packName += "_SCORM";
|
||
QString SCORMpath = projectPath + "/" + packName;
|
||
QDir SCORMdir = QDir(SCORMpath);
|
||
QElapsedTimer timer; timer.start();
|
||
if (SCORMdir.exists()) SCORMdir.removeRecursively();
|
||
SCORMdir.mkpath(".");
|
||
|
||
if(!isConsole) {
|
||
splash->SetTitle("Копирование служебных файлов...");
|
||
QApplication::processEvents();
|
||
}
|
||
|
||
copyDir(QCoreApplication::applicationDirPath()+"/Scorm", SCORMpath);
|
||
|
||
if(!isConsole)
|
||
splash->SetTitle("Формирование SCORM-пакета...");
|
||
QApplication::processEvents();
|
||
|
||
|
||
// enum OperatingSytem {OS_WINDOWS, OS_UNIX, OS_LINUX, OS_MAC} os;
|
||
// #if (defined (Q_OS_WIN) || defined (Q_OS_WIN32) || defined (Q_OS_WIN64))
|
||
// os = OS_WINDOWS;
|
||
// #elif (defined (Q_OS_UNIX))
|
||
// os = OS_UNIX;
|
||
// #elif (defined (Q_OS_LINUX))
|
||
// os = OS_LINUX;
|
||
// #elif (defined (Q_OS_MAC))
|
||
// os = OS_MAC;
|
||
// #endif
|
||
// QStringList params;
|
||
// if(os == OS_WINDOWS) {
|
||
// QString winpath1 = SCORMpath; winpath1.replace("/","\\");
|
||
// params << "/C"<<"xcopy"<<"/E" << "/C" << "/Y"<< QCoreApplication::applicationDirPath().replace("/","\\")+"\\Scorm\\*.*" << winpath1+"\\" << ">nul";
|
||
// QProcess::startDetached("cmd.exe", params);
|
||
// } else {
|
||
// params << "-R"<< QCoreApplication::applicationDirPath()+"/Scorm/*" << SCORMpath+"/" << "> /dev/null";
|
||
// QProcess::startDetached("cp", params);
|
||
// }
|
||
|
||
resetICN();
|
||
for(int i=0;i<items.count();i++) {
|
||
setCurItem(i);
|
||
QString _issueInfo = "identAndStatusSection.dmAddress.dmIdent.issueInfo";
|
||
QString _language = "identAndStatusSection.dmAddress.dmIdent.language";
|
||
if(item->schemeType == stLEARNING) {
|
||
item->SCORM_fileName = "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".xml";
|
||
if(QFile::exists(SCORMpath+"/" + item->SCORM_fileName)) QFile::remove(SCORMpath+"/" + item->SCORM_fileName);
|
||
if(!QFile::copy(projectPath+"/"+item->fileName, SCORMpath+"/" + item->SCORM_fileName))
|
||
if(DBG) qDebug() << "scorm: Error copy" << projectPath+"/"+item->fileName << "to" << SCORMpath+"/" + item->SCORM_fileName;
|
||
continue;
|
||
}
|
||
item->SCORM_fileName = "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".html";
|
||
}
|
||
|
||
for(int i=0;i<items.count();i++)
|
||
if(items[i].toExport && items[i].moduleType == mtDM) {
|
||
if(!isConsole) {
|
||
splash->SetTitle("Формирование SCORM-пакета..."); splash->Step();
|
||
QApplication::processEvents();
|
||
}
|
||
|
||
setCurItem(i);
|
||
if (!QFile::exists(projectPath + "/" + item->fileName)) {
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка","Файл "+projectPath + "/" + item->fileName+" не найден.");
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
QString htmlFileName = projectPath + "/" + item->fileName; htmlFileName.replace(".xml", ".html");
|
||
if (item->moduleType == mtDM && !QFile::exists(htmlFileName) && item->schemeType != stLEARNING) {
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка","Файл "+htmlFileName+" не найден.");
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
|
||
QFile htmlFile(htmlFileName);
|
||
if (!htmlFile.open(QFile::ReadOnly | QFile::Text)){
|
||
qDebug() << "scorm: file.open error "+htmlFileName;
|
||
return false;
|
||
}
|
||
QStringList htmlText = QString(htmlFile.readAll()).split("\n");
|
||
htmlFile.close();
|
||
|
||
for(int j=0;j<htmlText.count();j++) {
|
||
if(!isConsole) splash->Step();
|
||
|
||
QString s = "class=\"S1000Dmultimediaobj\"";
|
||
int k = htmlText[j].indexOf(s);
|
||
if(k > -1) {
|
||
s = "val=\"";
|
||
int m = htmlText[j].indexOf(s);
|
||
QString fn = htmlText[j].mid(m+s.length(), htmlText[j].indexOf("\"",m+s.length())-m-s.length());
|
||
QString icn = genICN();
|
||
QString icnfn = icn+"."+fn.split(".").last();
|
||
htmlText[j].replace(fn, icnfn);
|
||
//if(QFile::exists(SCORMpath+"/"+icnfn)) QFile::remove(SCORMpath+"/"+icnfn);
|
||
if(!QFile::exists(SCORMpath+"/"+icnfn))
|
||
if(!QFile::copy(projectPath+"/"+fn, SCORMpath+"/"+icnfn))
|
||
if(DBG) qDebug() << "scorm: Error copy" << projectPath+"/"+fn << "to" << SCORMpath+"/"+icnfn;
|
||
}
|
||
|
||
s = "<img ";
|
||
k = htmlText[j].indexOf(s);
|
||
if(k > -1) {
|
||
s = "src=\"";
|
||
int m = htmlText[j].indexOf(s);
|
||
QString fn = htmlText[j].mid(m+s.length(), htmlText[j].indexOf("\"",m+s.length())-m-s.length());
|
||
if(!fn.startsWith("app/")) {
|
||
QString icn = genICN();
|
||
QString icnfn = icn+"."+fn.split(".").last();
|
||
htmlText[j].replace(fn, icnfn);
|
||
//if(QFile::exists(SCORMpath+"/"+icnfn)) QFile::remove(SCORMpath+"/"+icnfn);
|
||
if(!QFile::exists(SCORMpath+"/"+icnfn))
|
||
if(!QFile::copy(projectPath+"/"+fn, SCORMpath+"/"+icnfn))
|
||
if(DBG) qDebug() << "scorm: Error copy" << projectPath+"/"+fn << "to" << SCORMpath+"/"+icnfn;
|
||
}
|
||
}
|
||
|
||
s = "onmousemove=\"showTooltipImg(evt, '";
|
||
k = htmlText[j].indexOf(s);
|
||
if(k > -1) {
|
||
QString fn = htmlText[j].mid(k+s.length(), htmlText[j].indexOf("'",k+s.length())-k-s.length());
|
||
QString icn = genICN();
|
||
QString icnfn = icn+"."+fn.split(".").last();
|
||
htmlText[j].replace(fn, icnfn);
|
||
//if(QFile::exists(SCORMpath+"/"+icnfn)) QFile::remove(SCORMpath+"/"+icnfn);
|
||
if(!QFile::exists(SCORMpath+"/"+icnfn))
|
||
if(!QFile::copy(projectPath+"/"+fn, SCORMpath+"/"+icnfn))
|
||
if(DBG) qDebug() << "scorm: Error copy" << projectPath+"/"+fn << "to" << SCORMpath+"/"+icnfn;
|
||
}
|
||
|
||
s = "<a href=\"";
|
||
k = htmlText[j].indexOf(s);
|
||
if(k > -1) {
|
||
QString fn = htmlText[j].mid(k+s.length(), htmlText[j].indexOf("\"",k+s.length())-k-s.length());
|
||
if(!fn.startsWith("#")) {
|
||
if(fn.contains(".html#")) { // межмодульная ссылка
|
||
fn = fn.left(fn.indexOf("#"));
|
||
QString name;
|
||
for(int n=0;n<items.count();n++) {
|
||
name = items[n].fileName;
|
||
name = name.replace(".xml", ".html");
|
||
if(fn == name) {
|
||
htmlText[j].replace(fn, items[n].SCORM_fileName);
|
||
name = "Ok"; break;
|
||
}
|
||
}
|
||
if(name != "Ok")
|
||
qDebug() << "HTML->SCORM - <a href: cant find DM "+fn;
|
||
}
|
||
else { // папки с Docs и т.д.
|
||
QDir dir(projectPath+"/"+fn.split("/")[0]);
|
||
QDir dir2(SCORMpath+"/"+fn.split("/")[0]);
|
||
if(dir.exists() && !dir2.exists())
|
||
if(!copyDir(projectPath+"/"+fn.split("/")[0], SCORMpath+"/"+fn.split("/")[0]))
|
||
{
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка", "href: Ошибка копирования:/n'"+projectPath+"/"+fn.split("/")[0]+"' в '"+SCORMpath+"/"+fn.split("/")[0]+"'");
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
} //#
|
||
} //<a href=
|
||
|
||
//s = "<iframe ";
|
||
s = "scRegister(";
|
||
k = htmlText[j].indexOf(s);
|
||
if(k > -1) {
|
||
//s = "src=\"";
|
||
//int m = htmlText[j].indexOf(s);
|
||
//QString fn = htmlText[j].mid(m+s.length(), htmlText[j].indexOf("\"",m+s.length())-m-s.length());
|
||
|
||
//scRegister('01060301-003.xml', 'title', 'd1', 'models/sc1.html');</script>
|
||
QList<QString> htmlSplit = htmlText[j].split("'");
|
||
QString fn = htmlSplit[ htmlSplit.count()-2];
|
||
|
||
QDir dir(projectPath+"/"+fn.split("/")[0]);
|
||
QDir dir2(SCORMpath+"/"+fn.split("/")[0]);
|
||
if(!dir.exists()) {
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка","ИМВС: Папка "+projectPath+"/"+fn.split("/")[0]+" не найдена.");
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
//qDebug() << "copy 3D: '"+projectPath+"/"+fn.split("/")[0]+"' to '"+S1000Dpath+"/"+fn.split("/")[0]+"'";
|
||
if(!dir2.exists())
|
||
if(!copyDir(projectPath+"/"+fn.split("/")[0], SCORMpath+"/"+fn.split("/")[0]))
|
||
{
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка", "ИМВС: Ошибка копирования:/n'"+projectPath+"/"+fn.split("/")[0]+"' в '"+SCORMpath+"/"+fn.split("/")[0]+"'");
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
} // <iframe
|
||
|
||
} //htmlText.count()
|
||
|
||
// <div class="S1000Dmultimediaobj" boardNum="video" val="video.mp4" actuate="onLoad" show="embed">
|
||
// <img src="1.1.1 XL.svg" alt="Показать" onmousemove="showZoomImg(event, '1.1.1 XL.svg');"/>
|
||
// NOT <img src="app/images/drive-drawing.svg" />
|
||
// <a href="aircraftmodel/index.html ">ИМВС</a>
|
||
// NOT <a href="#fig_002">
|
||
// onmousemove="showTooltipImg(evt, 'inline.svg');"
|
||
// <iframe src="fuselage/index.html" width="100%" height="580px" align="center">
|
||
|
||
if(QFile::exists(SCORMpath+"/" + item->SCORM_fileName)) QFile::remove(SCORMpath+"/" + item->SCORM_fileName);
|
||
QFile htmlOutFile(SCORMpath+"/" + item->SCORM_fileName);
|
||
if (htmlOutFile.open(QFile::WriteOnly | QFile::Text)) {
|
||
QTextStream out(&htmlOutFile); out.setCodec("UTF-8");
|
||
for(int j=0;j<htmlText.count();j++)
|
||
out << QString(htmlText[j]+"\n").toUtf8();
|
||
htmlOutFile.close();
|
||
}
|
||
} // items.count()
|
||
|
||
if(!isConsole) {
|
||
splash->SetTitle("Формирование манифеста..."); splash->Step();
|
||
QApplication::processEvents();
|
||
}
|
||
|
||
QDomDocument manifest;
|
||
QFile manFile(":new/BlankXML/imsmanifest.xml");
|
||
manFile.open(QFile::ReadOnly | QFile::Text);
|
||
manifest.setContent(manFile.readAll());
|
||
manFile.close();
|
||
manifest.namedItem("manifest").toElement().setAttribute("identifier", packName);
|
||
|
||
QString dt = QDateTime().currentDateTime().toString("dd.MM.yyyy hh:mm");
|
||
QDomNode dtNode = manifest.createElement("builddate");
|
||
dtNode.appendChild(manifest.createTextNode(dt));
|
||
manifest.namedItem("manifest").namedItem("metadata").appendChild(dtNode);
|
||
|
||
QDomNode organization = manifest.namedItem("manifest").namedItem("organizations").namedItem("organization");
|
||
QDomNode resources = manifest.namedItem("manifest").namedItem("resources");
|
||
|
||
QDomNode title = manifest.createElement("title");
|
||
organization.appendChild(title);
|
||
title.appendChild(manifest.createTextNode(packTitle));
|
||
|
||
|
||
QStringList htmlHead, htmlTail;
|
||
QFile blankFile(":new/BlankXML/scormIndex.html");
|
||
if (!blankFile.open(QFile::ReadOnly | QFile::Text)) return false;
|
||
QString s;
|
||
bool isHead = true;
|
||
while(!blankFile.atEnd()) {
|
||
s = QString::fromLocal8Bit(blankFile.readLine()).replace("\n","");
|
||
if(isHead) htmlHead.append(s); else htmlTail.append(s);
|
||
if(s.contains("<table id=\"tocTable\">")) isHead = false;
|
||
}
|
||
blankFile.close();
|
||
html.clear();
|
||
foreach(QString s, htmlHead)
|
||
addHTML(0, s);
|
||
|
||
for(int i=0;i<items.count();i++)
|
||
if(items[i].parent == -1)
|
||
fillManifest(i, organization, resources, manifest);
|
||
|
||
foreach(QString s, htmlTail)
|
||
addHTML(0, s);
|
||
|
||
QFile manOutFile(SCORMpath+"/imsmanifest.xml");
|
||
if (!manOutFile.open(QFile::WriteOnly | QFile::Text)) {
|
||
if(DBG) qDebug() << "scorm: Не удалось записать файл "+SCORMpath+"/imsmanifest.xml";
|
||
return false;
|
||
}
|
||
QTextStream outFile(&manOutFile);
|
||
manifest.save(outFile, 4);
|
||
manOutFile.close();
|
||
|
||
QFile htmlFile(SCORMpath+"/index.html");
|
||
if (htmlFile.open(QFile::ReadWrite | QFile::Text)) {
|
||
QTextStream out(&htmlFile); out.setCodec("UTF-8");
|
||
for(int i=0;i<html.count();i++)
|
||
out << QString(html[i]+"\n").toUtf8();
|
||
htmlFile.close();
|
||
}
|
||
|
||
if(!isConsole) {
|
||
splash->Reset(); splash->SetTitle("Создание ZIP-архива...");
|
||
}
|
||
if(QFile::exists(packDir+"/"+packName+".zip")) QFile::remove(packDir+"/"+packName+".zip");
|
||
enum OperatingSytem {OS_WINDOWS, OS_UNIX, OS_LINUX, OS_MAC} os;
|
||
#if (defined (Q_OS_WIN) || defined (Q_OS_WIN32) || defined (Q_OS_WIN64))
|
||
os = OS_WINDOWS;
|
||
#elif (defined (Q_OS_UNIX))
|
||
os = OS_UNIX;
|
||
#elif (defined (Q_OS_LINUX))
|
||
os = OS_LINUX;
|
||
#elif (defined (Q_OS_MAC))
|
||
os = OS_MAC;
|
||
#endif
|
||
QStringList params;
|
||
if(os == OS_WINDOWS)
|
||
{
|
||
params << "a"<<"-r"<<"-y" << QString(packDir+"/"+packName+".zip") << QString(SCORMpath+"/*.*") << ">nul";
|
||
QProcess pc;
|
||
pc.start(QString(QCoreApplication::applicationDirPath()+"/7z.exe"), params, QIODevice::ReadWrite);
|
||
if(pc.waitForStarted(2000))
|
||
while(!pc.waitForFinished(50)) {
|
||
if(!isConsole) {splash->Step();}
|
||
QCoreApplication::processEvents();
|
||
}
|
||
else {
|
||
qDebug() << "Failed to start 7z";
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
params << "a"<<"-r"<<"-y" << QString(packDir+"/"+packName+".zip") << QString(SCORMpath+"/*.*");// << ">nul";
|
||
QProcess pc;
|
||
pc.start("7z", params, QIODevice::ReadWrite);
|
||
if(pc.waitForStarted(2000))
|
||
while(!pc.waitForFinished(50))
|
||
{
|
||
if(!isConsole) {splash->Step();}
|
||
QCoreApplication::processEvents();
|
||
}
|
||
else {
|
||
qDebug() << "Failed to start 7z";
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
|
||
// QZipWriter zip(QString(dirName+"/"+packName+".zip").toLatin1());
|
||
// if (zip.status() != QZipWriter::NoError){
|
||
// if(DBG) qDebug() << "zip: Не удалось записать файл "+dirName+"/"+packName+".zip";
|
||
// return;
|
||
// }
|
||
// zip.setCompressionPolicy(QZipWriter::AutoCompress);
|
||
// splash->Reset(); splash->SetTitle("Создание ZIP-архива...");
|
||
|
||
// QString path = QString(SCORMpath+"/").toLatin1();
|
||
// QDirIterator it(path, QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot,
|
||
// QDirIterator::Subdirectories);
|
||
// while (it.hasNext()) {
|
||
// QCoreApplication::processEvents(); splash->Step();
|
||
// QString file_path = it.next();
|
||
// if (it.fileInfo().isDir()) {
|
||
// zip.setCreationPermissions(QFile::permissions(file_path));
|
||
// zip.addDirectory(file_path.remove(path));
|
||
// } else
|
||
// if (it.fileInfo().isFile()) {
|
||
// QFile file(file_path);
|
||
// if (!file.open(QIODevice::ReadOnly))
|
||
// continue;
|
||
// zip.setCreationPermissions(QFile::permissions(file_path));
|
||
// QByteArray ba = file.readAll();
|
||
// file.close();
|
||
// zip.addFile(file_path.remove(path), ba);
|
||
// }
|
||
// }
|
||
// zip.close();
|
||
|
||
timeSCORM = (int)timer.elapsed()/1000;
|
||
|
||
if(!isConsole) SaveProject();
|
||
SCORMdir.removeRecursively();
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return true;
|
||
}
|
||
|
||
bool S1000D_Manager::exportS1000D(QString dirName, QString packName, QString packTitle, SplashForm* splash) {
|
||
// функция так же требует расставленных флагов items[i].toExport
|
||
QElapsedTimer timer; timer.start();
|
||
|
||
QDomDocument dml;
|
||
QFile xmlFile(":new/BlankXML/dml.xml");
|
||
xmlFile.open(QFile::ReadOnly | QFile::Text);
|
||
dml.setContent(xmlFile.readAll());
|
||
xmlFile.close();
|
||
QDomNode dmlCode = dml.namedItem("dml").namedItem("identAndStatusSection").namedItem("dmlAddress").namedItem("dmlIdent").namedItem("dmlCode");
|
||
QDomNode dmlContent = dml.namedItem("dml").namedItem("dmlContent");
|
||
if(dmlCode.isNull()) qDebug() << "dmlCode.isNull";
|
||
QString identcode = items[0].doc.namedItem("pm").namedItem("identAndStatusSection").namedItem("pmAddress").namedItem("pmIdent").namedItem("pmCode").attributes().namedItem("modelIdentCode").nodeValue();
|
||
dmlCode.toElement().setAttribute("modelIdentCode", identcode);
|
||
dmlCode.toElement().setAttribute("senderIdent", ru_const.originator_enterpriseCode);
|
||
dmlCode.toElement().setAttribute("dmlType", "c");
|
||
dmlCode.toElement().setAttribute("yearOfDataIssue", QString::number(QDate::currentDate().year()));
|
||
dmlCode.toElement().setAttribute("seqNumber", "00001");
|
||
QString dmlFileName = "DML-"+identcode+"-"+ru_const.originator_enterpriseCode+"-C-"+QString::number(QDate::currentDate().year())+"-00001.xml";
|
||
|
||
QString S1000Dpath = projectPath + "/" + packName;
|
||
QDir S1000Ddir = QDir(S1000Dpath);
|
||
if (S1000Ddir.exists()) S1000Ddir.removeRecursively();
|
||
S1000Ddir.mkpath(".");
|
||
|
||
resetICN();
|
||
for(int i=0;i<items.count();i++)
|
||
if(items[i].toExport) {
|
||
if(!isConsole) splash->SetTitle("Формирование пакета S1000D...");
|
||
setCurItem(i);
|
||
if (!QFile::exists(projectPath + "/" + item->fileName)) {
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка","Файл "+projectPath + "/" + item->fileName+" не найден.");
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
|
||
QDomNode dmlEntry = dml.createElement("dmlEntry");
|
||
dmlContent.appendChild(dmlEntry);
|
||
|
||
if(item->moduleType == mtDM) {
|
||
QString _issueInfo = "identAndStatusSection.dmAddress.dmIdent.issueInfo";
|
||
QString _language = "identAndStatusSection.dmAddress.dmIdent.language";
|
||
item->S1000D_fileName = S1000Dpath+"/" + "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".xml";
|
||
|
||
QDomNode dmRef = dml.createElement("dmRef");
|
||
dmlEntry.appendChild(dmRef);
|
||
QDomNode dmRefIdent = dml.createElement("dmRefIdent");
|
||
dmRef.appendChild(dmRefIdent);
|
||
QDomNode dmCode = dml.importNode(findElement("identAndStatusSection.dmAddress.dmIdent.dmCode").cloneNode(), true);
|
||
dmRefIdent.appendChild(dmCode);
|
||
QDomNode issueInfo = dml.importNode(findElement("identAndStatusSection.dmAddress.dmIdent.issueInfo").cloneNode(), true);
|
||
dmRefIdent.appendChild(issueInfo);
|
||
QDomNode language = dml.importNode(findElement("identAndStatusSection.dmAddress.dmIdent.language").cloneNode(), true);
|
||
dmRefIdent.appendChild(language);
|
||
|
||
QDomNode dmRefAddressItems = dml.createElement("dmRefAddressItems");
|
||
dmRef.appendChild(dmRefAddressItems);
|
||
QDomNode dmTitle = dml.importNode(findElement("identAndStatusSection.dmAddress.dmAddressItems.dmTitle").cloneNode(), true);
|
||
dmRefAddressItems.appendChild(dmTitle);
|
||
QDomNode issueDate = dml.importNode(findElement("identAndStatusSection.dmAddress.dmAddressItems.issueDate").cloneNode(), true);
|
||
dmRefAddressItems.appendChild(issueDate);
|
||
}
|
||
if(item->moduleType == mtPM) {
|
||
//QString _issueInfo = "identAndStatusSection.pmAddress.pmIdent.issueInfo";
|
||
QString _language = "identAndStatusSection.pmAddress.pmIdent.language";
|
||
item->S1000D_fileName = S1000Dpath+"/" + "PMC-" + item->fileCode + "_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".xml";
|
||
|
||
QDomNode pmRef = dml.createElement("pmRef");
|
||
dmlEntry.appendChild(pmRef);
|
||
QDomNode pmRefIdent = dml.createElement("pmRefIdent");
|
||
pmRef.appendChild(pmRefIdent);
|
||
QDomNode dmCode = dml.importNode(findElement("identAndStatusSection.pmAddress.pmIdent.pmCode").cloneNode(), true);
|
||
pmRefIdent.appendChild(dmCode);
|
||
QDomNode issueInfo = dml.importNode(findElement("identAndStatusSection.pmAddress.pmIdent.issueInfo").cloneNode(), true);
|
||
pmRefIdent.appendChild(issueInfo);
|
||
QDomNode language = dml.importNode(findElement("identAndStatusSection.pmAddress.pmIdent.language").cloneNode(), true);
|
||
pmRefIdent.appendChild(language);
|
||
|
||
QDomNode pmRefAddressItems = dml.createElement("pmRefAddressItems");
|
||
pmRef.appendChild(pmRefAddressItems);
|
||
QDomNode pmTitle = dml.importNode(findElement("identAndStatusSection.pmAddress.pmAddressItems.pmTitle").cloneNode(), true);
|
||
pmRefAddressItems.appendChild(pmTitle);
|
||
QDomNode issueDate = dml.importNode(findElement("identAndStatusSection.pmAddress.pmAddressItems.issueDate").cloneNode(), true);
|
||
pmRefAddressItems.appendChild(issueDate);
|
||
}
|
||
|
||
//qDebug() << "copy "+projectPath + "/" + item->fileName +" "+ item->S1000D_fileName;
|
||
//if (QFile::exists(txtnewfilename)) QFile::remove(txtnewfilename);
|
||
//QFile::copy(projectPath + "/" + item->fileName, item->S1000D_fileName);
|
||
|
||
QFile xmlFile(projectPath + "/" + item->fileName);
|
||
if (!xmlFile.open(QFile::ReadOnly | QFile::Text))
|
||
{
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка","Ошибка открытия файла "+projectPath + "/" + item->fileName);
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
QStringList xmlText = QString(xmlFile.readAll()).split("\n");
|
||
xmlFile.close();
|
||
|
||
for(int j=0;j<xmlText.count();j++) {
|
||
if(!isConsole) splash->Step();
|
||
QString s = "<externalPubCode pubCodingScheme=\"file\">";
|
||
int k = xmlText[j].indexOf(s);
|
||
if(k > -1) {
|
||
QString fn = xmlText[j].mid(k+s.length(), xmlText[j].indexOf("</externalPubCode>")-k-s.length());
|
||
QDir dir(projectPath+"/"+fn.split("/")[0]);
|
||
if(!dir.exists()) {
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка","Папка "+projectPath+"/"+fn.split("/")[0]+" не найдена.");
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
|
||
//qDebug() << "copy externalPubCode: '"+projectPath+"/"+fn.split("/")[0]+"' to '"+S1000Dpath+"/"+fn.split("/")[0]+"'";
|
||
if(!copyDir(projectPath+"/"+fn.split("/")[0], S1000Dpath+"/"+fn.split("/")[0]))
|
||
{
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка", "Ошибка копирования:/n'"+projectPath+"/"+fn.split("/")[0]+"' в '"+S1000Dpath+"/"+fn.split("/")[0]+"'");
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
|
||
} //<externalPubCode
|
||
|
||
// Мультимедийные объекты (кроме видео и аудио): Текстовые метки, используемые в
|
||
// изображениях, должны быть выделены в отдельный список в формате XML.
|
||
// Программы обработки должны использовать идентификаторы меток для
|
||
// отображения их содержимого на поле изображения.
|
||
|
||
// Пример XML-разметки текстового элемента выноски в файле SVG, который будет хотспотом:
|
||
// <text x="49.982" y="93.168" stroke="none" fill="#000000"
|
||
// font-family="'Arial'" font-size="10" id="AUTOID_2501" class="6" >6</text>
|
||
|
||
//<div class="S1000Dfigure" id="fig0002">
|
||
// <div class="S1000Dfiguregraphic" boardNum="ICN-ANSAT-A-0313100-A-00000-00015-A-01-1" val="ICN-ANSAT-A-0313100-A-00000-00015-A-01-1.svg" actuate="onLoad" show="embed" id="fig0002-gra0001">
|
||
// <img src="app/images/drive-drawing.svg" alt="Показать" />
|
||
// <div class="S1000DHotspot" applicationStructureIdent="AUTOID_001" applicationStructureName="1" id="fig0002-gra0001-hot001" visibility="visible" hotspotTitle="Кабина пилотов"> </div>
|
||
// <div class="S1000DHotspot" applicationStructureIdent="AUTOID_002" applicationStructureName="2" id="fig0002-gra0001-hot002" visibility="visible" hotspotTitle="Правый щиток АЗС"> </div>
|
||
// <div class="S1000DHotspot" applicationStructureIdent="AUTOID_003" applicationStructureName="3" id="fig0002-gra0001-hot003" visibility="visible" hotspotTitle="Левый щиток АЗС"> </div>
|
||
// <div class="S1000DHotspot" applicationStructureIdent="AUTOID_004" applicationStructureName="4" id="fig0002-gra0001-hot004" visibility="visible" hotspotTitle="Хвостовая балка ШП2б-3б"> </div>
|
||
// </div>
|
||
s = "<multimediaObject ";
|
||
k = xmlText[j].indexOf(s);
|
||
if(k > -1) {
|
||
QString mms = xmlText[j].mid(k+s.length(), xmlText[j].indexOf("/>", k+s.length())-k-s.length());
|
||
int m = mms.indexOf("multimediaType=\"3D\"");
|
||
if(m > -1) {
|
||
s = "infoEntityIdent=\"";
|
||
QString fn = mms.mid(mms.indexOf(s)+s.length(), mms.indexOf("\"", mms.indexOf(s)+s.length()) - mms.indexOf(s)-s.length());
|
||
QDir dir(projectPath+"/"+fn.split("/")[0]);
|
||
if(!dir.exists()) {
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка","Папка "+projectPath+"/"+fn.split("/")[0]+" не найдена.");
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
|
||
//qDebug() << "copy 3D: '"+projectPath+"/"+fn.split("/")[0]+"' to '"+S1000Dpath+"/"+fn.split("/")[0]+"'";
|
||
if(!copyDir(projectPath+"/"+fn.split("/")[0], S1000Dpath+"/"+fn.split("/")[0]))
|
||
{
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка", "Ошибка копирования:/n'"+projectPath+"/"+fn.split("/")[0]+"' в '"+S1000Dpath+"/"+fn.split("/")[0]+"'");
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
};
|
||
|
||
}
|
||
|
||
m = mms.indexOf("multimediaType=\"video\"");
|
||
if(m > -1) {
|
||
s = "infoEntityIdent=\"";
|
||
QString fn = mms.mid(mms.indexOf(s)+s.length(), mms.indexOf("\"", mms.indexOf(s)+s.length()) - mms.indexOf(s)-s.length());
|
||
QString icn = genICN();
|
||
QString icnfn = icn+"."+fn.split(".").last();
|
||
xmlText[j].replace(fn, icnfn);
|
||
if(QFile::exists(S1000Dpath+"/"+icnfn)) QFile::remove(S1000Dpath+"/"+icnfn);
|
||
if(!QFile::copy(projectPath+"/"+fn, S1000Dpath+"/"+icnfn)) {
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка", "Ошибка копирования:/n'"+projectPath+"/"+fn + "to" + S1000Dpath+"/"+icnfn);
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
} // <multimediaObject
|
||
|
||
s = "<graphic ";
|
||
k = xmlText[j].indexOf(s);
|
||
if(k > -1) {
|
||
QString mms = xmlText[j].mid(k+s.length(), xmlText[j].indexOf("/>", k+s.length())-k-s.length());
|
||
|
||
s = "infoEntityIdent=\"";
|
||
QString fn = mms.mid(mms.indexOf(s)+s.length(), mms.indexOf("\"", mms.indexOf(s)+s.length()) - mms.indexOf(s)-s.length());
|
||
QString icn = genICN();
|
||
QString icnfn = icn+"."+fn.split(".").last();
|
||
xmlText[j].replace(fn, icnfn);
|
||
if(QFile::exists(S1000Dpath+"/"+icnfn)) QFile::remove(S1000Dpath+"/"+icnfn);
|
||
// if(fn.split(".").last().toLower() != "svg")
|
||
if(!QFile::copy(projectPath+"/"+fn, S1000Dpath+"/"+icnfn))
|
||
{
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка", "Ошибка копирования:/n'"+projectPath+"/"+fn + "to" + S1000Dpath+"/"+icnfn);
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
|
||
// if(fn.split(".").last().toLower() == "svg") {
|
||
// splash->SetTitle("Обработка SVG: "+ fn); splash->Step();
|
||
//QString txtoldfn = projectPath+"/"+fn.left(fn.length()-3)+"txt";
|
||
|
||
// QFile svgInFile(projectPath + "/" + fn);
|
||
// if (!svgInFile.open(QFile::ReadOnly | QFile::Text)) return;
|
||
// QStringList svgText = QString(svgInFile.readAll()).split("\n");
|
||
// svgInFile.close();
|
||
|
||
// if(QFile::exists(txtoldfn)) { // файл svg с хотспотами
|
||
// }
|
||
|
||
// if(QFile::exists(S1000Dpath+"/"+icnfn)) QFile::remove(S1000Dpath+"/"+icnfn);
|
||
// QFile svgOutFile(S1000Dpath+"/"+icnfn);
|
||
// QString svgheader = "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">";
|
||
// if (svgOutFile.open(QFile::WriteOnly | QFile::Text)) {
|
||
// QTextStream out(&svgOutFile); out.setCodec("UTF-8");
|
||
// for(int j=0;j<svgText.count();j++) {
|
||
// if(j == 1) {
|
||
// if(svgText[1] != svgheader)
|
||
// out << QString(svgheader+"\n").toUtf8();
|
||
// }
|
||
// out << QString(svgText[j]+"\n").toUtf8();
|
||
// }
|
||
// svgOutFile.close();
|
||
// }
|
||
// }
|
||
|
||
} // <graphic
|
||
|
||
s = "<hotspot ";
|
||
k = xmlText[j].indexOf(s);
|
||
if(k > -1) {
|
||
QString mms = xmlText[j].mid(k+s.length(), xmlText[j].indexOf("/>", k+s.length())-k-s.length());
|
||
int m = mms.indexOf("objectDescr=\"image\"");
|
||
s = "hotspotTitle=\"";
|
||
QString fn = mms.mid(mms.indexOf(s)+s.length(), mms.indexOf("\"", mms.indexOf(s)+s.length()) - mms.indexOf(s)-s.length());
|
||
if(m > -1 && fn != "") {
|
||
QString icn = genICN();
|
||
QString icnfn = icn+"."+fn.split(".").last();
|
||
xmlText[j].replace(fn, icnfn);
|
||
if(QFile::exists(S1000Dpath+"/"+icnfn)) QFile::remove(S1000Dpath+"/"+icnfn);
|
||
if(!QFile::copy(projectPath+"/"+fn, S1000Dpath+"/"+icnfn))
|
||
{
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка", "Ошибка копирования:/n'"+projectPath+"/"+fn + "to" + S1000Dpath+"/"+icnfn);
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
} // <hotspot
|
||
|
||
} // xmlText.count()
|
||
|
||
if(QFile::exists(item->S1000D_fileName)) QFile::remove(item->S1000D_fileName);
|
||
QFile xmlFile2(item->S1000D_fileName);
|
||
if (xmlFile2.open(QFile::WriteOnly | QFile::Text)) {
|
||
QTextStream out(&xmlFile2); out.setCodec("UTF-8");
|
||
for(int j=0;j<xmlText.count();j++)
|
||
out << QString(xmlText[j]+"\n").toUtf8();
|
||
xmlFile2.close();
|
||
}
|
||
|
||
} //items.count()
|
||
|
||
QFile dmlFile(S1000Dpath + "/" + dmlFileName);
|
||
if (!dmlFile.open(QFile::WriteOnly | QFile::Text))
|
||
{
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
splash->ErrMessage("Ошибка", "Не удалось записать файл "+S1000Dpath + "/" + dmlFileName);
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return false;
|
||
}
|
||
|
||
QTextStream outFile(&dmlFile);
|
||
dml.save(outFile, 4);
|
||
dmlFile.close();
|
||
|
||
|
||
if(!isConsole) {splash->Reset(); splash->SetTitle("Создание ZIP-архива...");}
|
||
if(QFile::exists(dirName+"/"+packName+".zip")) QFile::remove(dirName+"/"+packName+".zip");
|
||
enum OperatingSytem {OS_WINDOWS, OS_UNIX, OS_LINUX, OS_MAC} os;
|
||
#if (defined (Q_OS_WIN) || defined (Q_OS_WIN32) || defined (Q_OS_WIN64))
|
||
os = OS_WINDOWS;
|
||
#elif (defined (Q_OS_UNIX))
|
||
os = OS_UNIX;
|
||
#elif (defined (Q_OS_LINUX))
|
||
os = OS_LINUX;
|
||
#elif (defined (Q_OS_MAC))
|
||
os = OS_MAC;
|
||
#endif
|
||
QStringList params;
|
||
if(os == OS_WINDOWS) {
|
||
params << "a"<<"-r"<<"-y" << QString(dirName+"/"+packName+".zip") << QString(S1000Dpath+"/*.*") << ">nul";
|
||
QProcess pc;
|
||
pc.start(QString(QCoreApplication::applicationDirPath()+"/7z.exe"), params, QIODevice::ReadWrite);
|
||
while(!pc.waitForFinished(50)) {
|
||
if(!isConsole)
|
||
{splash->Step(); splash->Step(); splash->Step(); }
|
||
QCoreApplication::processEvents();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
params << "a"<<"-r"<<"-y" << QString(dirName+"/"+packName+".zip") << QString(S1000Dpath+"/*.*") << ">nul";
|
||
QProcess pc;
|
||
pc.start("7z", params, QIODevice::ReadWrite);
|
||
while(!pc.waitForFinished(50)) {
|
||
if(!isConsole)
|
||
{splash->Step(); splash->Step(); splash->Step(); }
|
||
QCoreApplication::processEvents();
|
||
}
|
||
}
|
||
|
||
// if(QFile::exists(dirName+"/"+packName+".zip")) QFile::remove(dirName+"/"+packName+".zip");
|
||
// QZipWriter zip(QString(dirName+"/"+packName+".zip").toLatin1());
|
||
// if (zip.status() != QZipWriter::NoError){
|
||
// if(DBG) qDebug() << "zip: Не удалось записать файл "+dirName+"/"+packName+".zip";
|
||
// return;
|
||
// }
|
||
// zip.setCompressionPolicy(QZipWriter::AutoCompress);
|
||
// splash->Reset(); splash->SetTitle("Создание ZIP-архива...");
|
||
|
||
// QString path = QString(S1000Dpath+"/").toLatin1();
|
||
// QDirIterator it(path, QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot,
|
||
// QDirIterator::Subdirectories);
|
||
// while (it.hasNext()) {
|
||
// QCoreApplication::processEvents(); splash->Step();
|
||
// QString file_path = it.next();
|
||
// if (it.fileInfo().isDir()) {
|
||
// zip.setCreationPermissions(QFile::permissions(file_path));
|
||
// zip.addDirectory(file_path.remove(path));
|
||
// } else
|
||
// if (it.fileInfo().isFile()) {
|
||
// QFile file(file_path);
|
||
// if (!file.open(QIODevice::ReadOnly))
|
||
// continue;
|
||
// zip.setCreationPermissions(QFile::permissions(file_path));
|
||
// QByteArray ba = file.readAll();
|
||
// file.close();
|
||
// zip.addFile(file_path.remove(path), ba);
|
||
// }
|
||
// }
|
||
// zip.close();
|
||
|
||
timeS1000D = (int)timer.elapsed()/1000;
|
||
|
||
SaveProject();
|
||
S1000Ddir.removeRecursively();
|
||
if(!isConsole) {
|
||
splash->hide();
|
||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
return true;
|
||
}
|
||
|
||
/*
|
||
void S1000D_Manager::searchPrepare() {
|
||
item->searchList.clear();
|
||
QList<QDomNode> nodeList;
|
||
nodeList.append(item->doc.namedItem("dmodule"));
|
||
QDomNode node;
|
||
while(!nodeList.isEmpty()) {
|
||
node = nodeList.takeFirst();
|
||
searchListStruct sItem;
|
||
sItem.name = node.nodeName(); sItem.node = node;
|
||
item->searchList.append(sItem);
|
||
for(int k=0;k<node.childNodes().count();k++)
|
||
nodeList.append(node.childNodes().at(k));
|
||
}
|
||
}
|
||
|
||
QDomNode S1000D_Manager::searchNodeWithTag(QString tag) { //QDomNode startNode,
|
||
for(int i=0;i<item->searchList.count();i++)
|
||
if(item->searchList[i].name == tag) {
|
||
qDebug() << "Found node " + tag;
|
||
return item->searchList[i].node;
|
||
}
|
||
QDomNode nullNode;
|
||
return nullNode;
|
||
}
|
||
|
||
QDomNode S1000D_Manager::searchNodeWithAttr(QString attrName, QString attrVal) { //QDomNode startNode,
|
||
for(int i=0;i<item->searchList.count();i++) {
|
||
if(item->searchList[i].node.toElement().hasAttribute(attrName) && item->searchList[i].node.toElement().attribute(attrName) == attrVal)
|
||
return item->searchList[i].node;
|
||
}
|
||
QDomNode nullNode;
|
||
return nullNode;
|
||
}
|
||
*/
|
||
|
||
// targetPath="//lcInstruction/description/levelledPara[attribute::id = 'para-000' and child::levelledPara[fn:position() = 1]]"
|
||
|
||
QString S1000D_Manager::makeNodeXPath(QDomNode node) {
|
||
if(item->doc.namedItem("dmodule").childNodes().count() == 0)
|
||
qDebug() << "Empty item: " << itemIndex << item->fileName << item->doc.namedItem("dmodule").nodeName() << item->doc.namedItem("dmodule").childNodes().count();
|
||
//else
|
||
// qDebug() << itemIndex << "Ok";
|
||
|
||
QString path="";
|
||
QString pos;
|
||
int ind=-1, cnt=0;
|
||
QDomNode cur = node;
|
||
QDomNode chNode;
|
||
//if(node.nodeName() == "blankRefNode9")
|
||
// qDebug() << "blankRefNode9 debug";
|
||
while(1) {
|
||
pos = "";
|
||
if(!cur.parentNode().isNull()) {
|
||
cnt = 0; ind = 0;
|
||
for(int i=0;i<cur.parentNode().childNodes().count();i++) {
|
||
chNode = cur.parentNode().childNodes().at(i);
|
||
if(chNode.nodeName() == cur.nodeName())
|
||
cnt++;
|
||
if(chNode == cur) {
|
||
//if(node.nodeName() == "blankRefNode9")
|
||
// qDebug() << "blankRefNode9 debug: " << "cur: " << cur.nodeName() << cnt << " parent: " << cur.parentNode().nodeName();
|
||
ind = cnt;
|
||
}
|
||
}
|
||
if(cnt > 1)
|
||
pos = "["+QString::number(ind)+"]";
|
||
}
|
||
|
||
path = "/"+cur.nodeName()+pos+path;
|
||
|
||
if(cur.parentNode().isNull() || cur.parentNode().nodeName() == "#document") {
|
||
//if(cur.parentNode().nodeName() != "#document")
|
||
// qDebug() << "makeNodeXPath: parentNode("+cur.nodeName()+").isNull";
|
||
break;
|
||
}
|
||
cur = cur.parentNode();
|
||
};
|
||
|
||
QDomNode nd = getNodeFromXPath(path); //, true
|
||
if(nd.nodeName() != node.nodeName())
|
||
qDebug() << "makeNodeXPath fail: Need "+node.nodeName()+node.nodeType()+" Found "+nd.nodeName()+nd.nodeType()+" Path "+path+"";
|
||
//else
|
||
// qDebug() << "makeNodeXPath OK";
|
||
|
||
//if(path.contains("description/para")) {
|
||
// qDebug() << "makeNodeXPath: description/para !! " << path << item->fileName;
|
||
//}
|
||
|
||
return path;
|
||
}
|
||
|
||
QDomNode S1000D_Manager::getNodeFromXPath(QString path, bool debugTrace) {
|
||
QStringList list = path.mid(1).split("/");
|
||
if(debugTrace) qDebug() << "getNodeFromXPath: "+path;
|
||
|
||
QDomNode node = item->doc.namedItem("dmodule").parentNode(); //namedItem("dmodule").parentNode(); //namedItem("#document")
|
||
if(node.isNull()) {
|
||
//if(debugTrace)
|
||
qDebug() << " node is NULL: item->doc.namedItem(dmodule).parentNode()";
|
||
if(debugTrace) qDebug() << " " << itemIndex << item->fileName << item->doc.namedItem("dmodule").nodeName() << item->doc.namedItem("dmodule").childNodes().count();
|
||
if(debugTrace)
|
||
for(int i=0;i<item->doc.childNodes().count();i++) {
|
||
qDebug() << " " << item->doc.childNodes().at(i).nodeName() << item->doc.childNodes().at(i).childNodes().count();
|
||
for(int j=0;j<item->doc.childNodes().at(i).childNodes().count();j++) {
|
||
qDebug() << " " << item->doc.childNodes().at(i).childNodes().at(j).nodeName() << item->doc.childNodes().at(i).childNodes().at(j).childNodes().count();
|
||
for(int k=0;k<item->doc.childNodes().at(i).childNodes().at(j).childNodes().count();k++)
|
||
qDebug() << " " << item->doc.childNodes().at(i).childNodes().at(j).childNodes().at(k).nodeName() << item->doc.childNodes().at(i).childNodes().at(j).childNodes().at(k).childNodes().count();
|
||
}
|
||
}
|
||
QDomNode nullNode;
|
||
return nullNode;
|
||
}
|
||
|
||
int pos;
|
||
if(debugTrace) qDebug() << " ------------------------- ";
|
||
while(list.count() > 0) {
|
||
if(debugTrace) {
|
||
qDebug() << " node: "+node.nodeName()+" child cnt: "+QString::number(node.childNodes().count());
|
||
for(int i=0;i<node.childNodes().count();i++)
|
||
qDebug() << " "+node.childNodes().at(i).nodeName();
|
||
}
|
||
QString name = list.takeFirst();
|
||
int b = name.indexOf("[");
|
||
QString _name = name.mid(0, b);
|
||
if(b == -1)
|
||
node = node.namedItem(name);
|
||
else {
|
||
pos = name.mid(b+1, name.indexOf("]")-(b+1)).toInt();
|
||
int cnt=0;
|
||
bool found = false;
|
||
for(int i=0;i<node.childNodes().count();i++) {
|
||
if(node.childNodes().at(i).nodeName() == _name)
|
||
cnt++;
|
||
if(cnt == pos) {
|
||
node = node.childNodes().at(i);
|
||
found = true;
|
||
break;
|
||
}
|
||
}
|
||
if(!found) {
|
||
qDebug() << "getNodeFromXPath: node "+_name+" at pos "+name.mid(b+1, name.indexOf("]")-(b+1))+" NOT FOUND ("+path+")";
|
||
//for(int i=0;i<node.childNodes().count();i++)
|
||
// qDebug() << " "+node.childNodes().at(i).nodeName();
|
||
QDomNode nullNode;
|
||
return nullNode;
|
||
}
|
||
}
|
||
if(debugTrace) qDebug() << " need: "+name+" found: "+node.nodeName();
|
||
}
|
||
|
||
if(debugTrace) qDebug() << "--Result node: "+node.nodeName();
|
||
//if(!node.nodeName().startsWith("blankRefNode"))
|
||
// qDebug() << "Rename "+node.nodeName()+" to REF ("+path+")";
|
||
return node;
|
||
}
|
||
|
||
|
||
/*
|
||
<identAndStatusSection>
|
||
<pmAddress>
|
||
<pmIdent>
|
||
<pmCode pmIssuer="B6865" pmVolume="" modelIdentCode="S1000DBIKE" pmNumber="GTC"/>
|
||
<language countryIsoCode="US" languageIsoCode="sx"/>
|
||
<issueInfo inWork="00" issueNumber="004"/>
|
||
</pmIdent>
|
||
<pmAddressItems>
|
||
<issueDate day="28" month="06" year="2019"/>
|
||
<pmTitle>АУК ОБЩЕГО ПРИМЕНЕНИЯ</pmTitle>
|
||
<shortPmTitle>BIKE</shortPmTitle>
|
||
</pmAddressItems>
|
||
|
||
|
||
<content> 5.0
|
||
<pmEntry>
|
||
<pmRef>
|
||
<pmRefIdent>
|
||
<pmCode pmIssuer="RHC01" pmVolume="00" modelIdentCode="RHCT" pmNumber="RTC04"/>
|
||
<issueInfo inWork="00" issueNumber="004"/>
|
||
<language countryIsoCode="US" languageIsoCode="sx"/>
|
||
</pmRefIdent>
|
||
<pmRefAddressItems>
|
||
<pmTitle>Publication for all BRAKE data modules</pmTitle>
|
||
<issueDate day="28" month="06" year="2019"/>
|
||
</pmRefAddressItems>
|
||
<content> 4.1
|
||
<pmEntry>
|
||
<pmEntryTitle>List of applicable publications</pmEntryTitle>
|
||
<pmEntry>
|
||
<pmEntryTitle>Bicycle</pmEntryTitle>
|
||
<pmRef>
|
||
...
|
||
*/
|
||
|
||
|
||
/*
|
||
// В файлах схем на сайте www.s1000d.org присутствует некорректное (возможно устаревшее) регулярное выражение
|
||
// ([A-Z-[IO]]{1}) которое не проходит валидацию современными требованиями к регулярным выражениям, в т.ч. с использованием QXmlSchemaValidator
|
||
// Правильная запись: ?(?=[A-Z])[^IO]|^$){1}
|
||
bool S1000D_Manager::validateXML(const QString &xsdschema, const QString &xmlschema)
|
||
{
|
||
bool flag = false;
|
||
QFile xsdfile(xsdschema);
|
||
if(!xsdfile.open(QIODevice::ReadOnly)){
|
||
flag = false;
|
||
}
|
||
QXmlSchema schema;
|
||
if(schema.load(&xsdfile, QUrl::fromLocalFile(xsdfile.fileName()))){
|
||
if(schema.isValid()){
|
||
QFile xmlfile(xmlschema);
|
||
if(!xmlfile.open(QIODevice::ReadOnly)){
|
||
flag = false;
|
||
}
|
||
QXmlSchemaValidator xmlvalidator(schema);
|
||
if(xmlvalidator.validate(&xmlfile, QUrl::fromLocalFile(xmlfile.fileName()))){
|
||
flag = true;
|
||
}
|
||
}
|
||
}
|
||
return flag;
|
||
} */
|
||
|
||
/*
|
||
KVS - КВС - командир воздушного судна
|
||
2P - 2П - второй пилот
|
||
IVD - ИВД - инженер ВД (вертолет и двигатель)
|
||
IAO - ИАО - инженер АО (авиационное оборудование)
|
||
IREO - ИРЭО - инженер РЭО (радиоэлектронное оборудование)
|
||
ITO - ИТО - инженер ТО (транспортное оборудование)
|
||
BP - БП - бортпроводник
|
||
BO - БО - бортовой оператор
|
||
*/
|