/// <summary> /// Creates NPMCharacters from the SpecialCharacterRows and counts them by category when needes. /// </summary> private void setNpmCharacters() { Dictionary <string, SpecialCharacterRow> specialCharacterRows = mMeta.MetaQuery.GetSpecialCharacterAllRows(); myNPMCharacters = new Dictionary <string, NPMCharacter>(); foreach (KeyValuePair <string, SpecialCharacterRow> myRow in specialCharacterRows) { NPMCharacter myNPMCharacter = new NPMCharacter(myRow, mMeta); // Category 1 if (myNPMCharacter.category == 1) { //cat1Counter++; } // category 2 else if (myNPMCharacter.category == 2) { myNPMCharacter.pcAxisCode = PcAxisCodes.DataSymbol_NIL; cat2Counter++; if (cat2Counter > 1) { throw new PCAxis.Sql.Exceptions.DbException(15); } } // category 3 else if (myNPMCharacter.category == 3) { // check to se if any of the character is the same as the one specified for DataSymbolSum. if (myNPMCharacter.characterType == SpecialCharacterIDbyMetaAdmProprety[mMeta.Config.Keywords.DataSymbolSum]) { myNPMCharacter.pcAxisCode = PcAxisCodes.DataSymbol_Sum; //could have done dataSymbolSumNPMCharacter = myNPMCharacter; , but // for the others it is done in setMetaAdm() so I put it there for this as well. } else { cat3Counter++; if (cat3Counter > 6) { throw new PCAxis.Sql.Exceptions.DbException(16); } else { myNPMCharacter.dataSymbolNr = cat3Counter; myNPMCharacter.pcAxisCode = PcAxisCodes.getDataSymbolNo(cat3Counter); } } } else { throw new PCAxis.Sql.Exceptions.DbException(17); } myNPMCharacters.Add(myNPMCharacter.characterType, myNPMCharacter); } }
internal double DataSymbolNMagic(string characterType) { if (myNPMCharacters.ContainsKey(characterType)) { NPMCharacter myChar = myNPMCharacters[characterType]; return(myChar.pcAxisCode); } throw new PCAxis.Sql.Exceptions.DbException(31, characterType); }
/// <summary> /// Checks, for the SpecialCharacters that are "extra Special, that is, that are (must be) given a meaning in MetaAdm /// that the category is acceptable for meaning, and assigns the correct NPMCharacter to the "meaningNPMCharacter" fields /// </summary> private void setMetaAdm() { string idToCheck; NPMCharacter npmChar; // DefaultCodeMissingLine //defaultCodeMissingLine The value for defaultCodeMissingLine should be specified in SpecialCharacter and // should be of category 2 or 3: // check if variables was found in the NPM table. idToCheck = SpecialCharacterIDbyMetaAdmProprety[mMeta.Config.Keywords.DefaultCodeMissingLine]; if (!myNPMCharacters.ContainsKey(idToCheck)) { throw new PCAxis.Sql.Exceptions.DbException(18, mMeta.Config.Keywords.DefaultCodeMissingLine, idToCheck); } npmChar = myNPMCharacters[idToCheck]; if ((npmChar.category == 2) || (npmChar.category == 3)) { defaultCodeMissingLineNPMCharacter = npmChar; } else { throw new PCAxis.Sql.Exceptions.DbException(20, mMeta.Config.Keywords.DefaultCodeMissingLine, idToCheck, npmChar.category, "2 or 3"); } //DataSymbolNil //DatasymbolNil should be of category 2 idToCheck = SpecialCharacterIDbyMetaAdmProprety[mMeta.Config.Keywords.DataSymbolNIL]; if (!myNPMCharacters.ContainsKey(idToCheck)) { throw new PCAxis.Sql.Exceptions.DbException(18, mMeta.Config.Keywords.DataSymbolNIL, idToCheck); } npmChar = myNPMCharacters[idToCheck]; if (npmChar.category == 2) { dataSymbolNilNPMCharacter = npmChar; } else { throw new PCAxis.Sql.Exceptions.DbException(20, mMeta.Config.Keywords.DataSymbolNIL, idToCheck, npmChar.category, "2"); } // DataNotAvailable sjekker at koden fra metaadm finnes i SpesChar med riktig category // DataNotAvailable should be of category 3 idToCheck = SpecialCharacterIDbyMetaAdmProprety[mMeta.Config.Keywords.DataNotAvailable]; if (!myNPMCharacters.ContainsKey(idToCheck)) { throw new PCAxis.Sql.Exceptions.DbException(18, mMeta.Config.Keywords.DataNotAvailable, idToCheck); } npmChar = myNPMCharacters[idToCheck]; if (npmChar.category == 3) { dataNotAvailableNPMCharacter = npmChar; } else { throw new PCAxis.Sql.Exceptions.DbException(20, mMeta.Config.Keywords.DataNotAvailable, idToCheck, npmChar.category, "3"); } // DataNoteSum sjekker at koden fra metaadm finnes i SpesChar med riktig category idToCheck = SpecialCharacterIDbyMetaAdmProprety[mMeta.Config.Keywords.DataNoteSum]; if (!myNPMCharacters.ContainsKey(idToCheck)) { throw new PCAxis.Sql.Exceptions.DbException(18, mMeta.Config.Keywords.DataNoteSum, idToCheck); } npmChar = myNPMCharacters[idToCheck]; if (npmChar.category == 1) { dataNoteSumNPMCharacter = npmChar; } else { throw new PCAxis.Sql.Exceptions.DbException(20, mMeta.Config.Keywords.DataNoteSum, idToCheck, npmChar.category, "1"); } //DataSymbolSum idToCheck = SpecialCharacterIDbyMetaAdmProprety[mMeta.Config.Keywords.DataSymbolSum]; if (!myNPMCharacters.ContainsKey(idToCheck)) { throw new PCAxis.Sql.Exceptions.DbException(18, mMeta.Config.Keywords.DataSymbolSum, idToCheck); } npmChar = myNPMCharacters[idToCheck]; if (npmChar.category == 3) { dataSymbolSumNPMCharacter = npmChar; } else { throw new PCAxis.Sql.Exceptions.DbException(20, mMeta.Config.Keywords.DataSymbolSum, idToCheck, npmChar.category, "3"); } }
public PXSqlNpm(PXSqlMeta_21 mMeta) { this.mMeta = mMeta; metaVersion = mMeta.MetaModelVersion; cat1Counter = 0; cat2Counter = 0; cat3Counter = 0; myMetaAdmVariables = new Dictionary <string, MetaAdmVariable>(); if (metaVersion == "2.0") { NPMCharacter myNPMCharacter = new NPMCharacter(); //myNPMCharacters = new Dictionary<int, NPMCharacter>(); myNPMCharacters = new List <NPMCharacter>(); myNPMCharacter.id = 0; myNPMCharacter.category = 3; //myNPMCharacter.pcAxisCode = PcAxisCodes.getDataSymbolNo(1); myNPMCharacter.pcAxisCode = PcAxisCodes.getDataSymbolNo(2); //TODO; FIX (tja 2.1) myNPMCharacter.presCharacters = new Dictionary <string, string>(); myNPMCharacter.presTexts = new Dictionary <string, string>(); foreach (string lang in mMeta.LanguageCodes) { myNPMCharacter.presCharacters[lang] = ".."; myNPMCharacter.presTexts[lang] = ""; } myNPMCharacters.Add(myNPMCharacter); // Set MetaAdmvariable for DataNotAvailable MetaAdmVariable myMetaVariable = new MetaAdmVariable(); myMetaVariable.name = dataNotAvailable; myMetaVariable.value = ""; myMetaVariable.npmRef = 0; myMetaAdmVariables.Add(myMetaVariable.name, myMetaVariable); //TODO; FIX (tja 2.1) //myMetaVariable = new MetaAdmVariable(); //myMetaVariable.name = dataSymbolSum; //myMetaVariable.value = ""; //myMetaVariable.npmRef = 0; //myMetaAdmVariables.Add(myMetaVariable.name, myMetaVariable); //myMetaVariable = new MetaAdmVariable(); //myMetaVariable.name = dataSymbolNIL; //myMetaVariable.value = ""; //myMetaVariable.npmRef = 0; //myMetaAdmVariables.Add(myMetaVariable.name, myMetaVariable); //myMetaVariable = new MetaAdmVariable(); //myMetaVariable.name = dataNoteSum; //myMetaVariable.value = ""; //myMetaVariable.npmRef = 0; //myMetaAdmVariables.Add(myMetaVariable.name, myMetaVariable); //---------------- } else if (String.Compare(metaVersion, "2.0", false, CultureInfo.InvariantCulture) > 0) { //if ((metaVersion == (decimal)2.1) || (metaVersion == (decimal)2.2)) //DataNotAvailable myMetaAdmRow = mMeta.MetaQuery.GetMetaAdmRow(dataNotAvailable); setMetaAdmInfo1(myMetaAdmRow); //DATANOTESUM myMetaAdmRow = mMeta.MetaQuery.GetMetaAdmRow(dataNoteSum); setMetaAdmInfo1(myMetaAdmRow); //DATASYMBOLNIL myMetaAdmRow = mMeta.MetaQuery.GetMetaAdmRow(dataSymbolNIL); setMetaAdmInfo1(myMetaAdmRow); //DATASYMBOLSUM myMetaAdmRow = mMeta.MetaQuery.GetMetaAdmRow(dataSymbolSum); setMetaAdmInfo1(myMetaAdmRow); //DEFAULTCODEMISSINGLINE myMetaAdmRow = mMeta.MetaQuery.GetMetaAdmRow(defaultCodeMissingLine); setMetaAdmInfo1(myMetaAdmRow); // assign properties for specialcharacters setNpmCharacters(); setMetaAdm(); maxDatasymbolN = cat3Counter; } else { throw new PCAxis.Sql.Exceptions.DbPxsMismatchException(14, mMeta.MetaModelVersion); } }
protected void setMetaAdm() { MetaAdmVariable varToCheck; // DefaultCodeMissingLine //defaultCodeMissingLine The value for defaultCodeMissingLine should be specified in SpecialCharacter and // should be of category 2 or 3: // check if variables was found in the NPM table. varToCheck = myMetaAdmVariables[defaultCodeMissingLine]; foreach (NPMCharacter npmChar in myNPMCharacters) { if ((npmChar.category == 2) || (npmChar.category == 3)) { if (varToCheck.value == npmChar.characterType) { varToCheck.npmRef = npmChar.id; defaultCodeMissingLineSet = true; break; } } } if (!defaultCodeMissingLineSet) { throw new PCAxis.Sql.Exceptions.DbException(18); } //DataSymbolNil //DatasymbolNil should be of category 2 varToCheck = myMetaAdmVariables[dataSymbolNIL]; foreach (NPMCharacter npmChar in myNPMCharacters) { if (npmChar.category == 2) { if (((metaVersion == "2.1") && (varToCheck.value == npmChar.presCharacters[mMeta.LanguageCodes[0]])) || ((metaVersion == "2.2") && (varToCheck.value == npmChar.characterType))) { varToCheck.npmRef = npmChar.id; dataSymbolNilSet = true; break; } } } if (!dataSymbolNilSet) { if (metaVersion == "2.1") { if (cat2Counter < 1) { NPMCharacter myNPMCharacter = new NPMCharacter(); myNPMCharacter.id = npmId; myNPMCharacter.category = 2; myNPMCharacter.pcAxisCode = PcAxisCodes.getDatasymbolNil(); Dictionary <string, string> myPresTexts = new Dictionary <string, string>(); Dictionary <string, string> myPresCharacters = new Dictionary <string, string>(); foreach (string lang in mMeta.LanguageCodes) { myPresTexts.Add(lang, ""); myPresCharacters.Add(lang, varToCheck.value); } myNPMCharacter.presCharacters = myPresCharacters; myNPMCharacter.presTexts = myPresTexts; myNPMCharacters.Add(myNPMCharacter); varToCheck.npmRef = myNPMCharacter.id; npmId++; cat2Counter++; } else { throw new PCAxis.Sql.Exceptions.DbException(19); } } else { throw new PCAxis.Sql.Exceptions.DbException(20, dataSymbolNIL); } } // DataNotAvailable // DataNotAvailable should be of category 3 varToCheck = myMetaAdmVariables[dataNotAvailable]; foreach (NPMCharacter npmChar in myNPMCharacters) { if (npmChar.category == 3) { if (((metaVersion == "2.1") && (varToCheck.value == npmChar.presCharacters[mMeta.LanguageCodes[0]])) || ((metaVersion == "2.2") && (varToCheck.value == npmChar.characterType))) { varToCheck.npmRef = npmChar.id; dataNotAvailableSet = true; break; } } } if (!dataNotAvailableSet) { if (metaVersion == "2.1") { if (cat3Counter <= 6) { NPMCharacter myNPMCharacter = new NPMCharacter(); myNPMCharacter.id = npmId; myNPMCharacter.category = 3; myNPMCharacter.dataSymbolNr = cat3Counter + 1; myNPMCharacter.pcAxisCode = PcAxisCodes.getDataSymbolNo(cat3Counter + 1); Dictionary <string, string> myPresTexts = new Dictionary <string, string>(); Dictionary <string, string> myPresCharacters = new Dictionary <string, string>(); foreach (string lang in mMeta.LanguageCodes) { myPresTexts.Add(lang, ""); myPresCharacters.Add(lang, varToCheck.value); } myNPMCharacter.presCharacters = myPresCharacters; myNPMCharacter.presTexts = myPresTexts; myNPMCharacters.Add(myNPMCharacter); varToCheck.npmRef = myNPMCharacter.id; cat3Counter++; npmId++; } else { throw new PCAxis.Sql.Exceptions.DbException(21); } } else { throw new PCAxis.Sql.Exceptions.DbException(22, dataNotAvailable); } } // DataNoteSum varToCheck = myMetaAdmVariables[dataNoteSum]; foreach (NPMCharacter npmChar in myNPMCharacters) { if (npmChar.category == 1) { if (((metaVersion == "2.1") && (varToCheck.value == npmChar.presCharacters[mMeta.LanguageCodes[0]])) || ((metaVersion == "2.2") && (varToCheck.value == npmChar.characterType))) { varToCheck.npmRef = npmChar.id; dataNoteSumSet = true; break; } } } if (!dataNoteSumSet) { if (metaVersion == "2.1") { NPMCharacter myNPMCharacter = new NPMCharacter(); myNPMCharacter.id = npmId; myNPMCharacter.category = 1; Dictionary <string, string> myPresTexts = new Dictionary <string, string>(); Dictionary <string, string> myPresCharacters = new Dictionary <string, string>(); foreach (string lang in mMeta.LanguageCodes) { myPresTexts.Add(lang, ""); myPresCharacters.Add(lang, varToCheck.value); } myNPMCharacter.presCharacters = myPresCharacters; myNPMCharacter.presTexts = myPresTexts; myNPMCharacters.Add(myNPMCharacter); varToCheck.npmRef = myNPMCharacter.id; cat1Counter++; npmId++; } else { throw new PCAxis.Sql.Exceptions.DbException(23, dataNoteSum); } } //DataSymbolSum varToCheck = myMetaAdmVariables[dataSymbolSum]; if (dataSymbolSumSet) { varToCheck.npmRef = dataSymbolSumNpmId; } else { if (metaVersion == "2.1") { if (cat3Counter < 6) { NPMCharacter myNPMCharacter = new NPMCharacter(); myNPMCharacter.id = npmId; myNPMCharacter.category = 3; myNPMCharacter.dataSymbolNr = cat3Counter + 1; myNPMCharacter.pcAxisCode = PcAxisCodes.getDataSymbolNo(cat3Counter + 1); Dictionary <string, string> myPresTexts = new Dictionary <string, string>(); Dictionary <string, string> myPresCharacters = new Dictionary <string, string>(); foreach (string lang in mMeta.LanguageCodes) { myPresTexts.Add(lang, ""); myPresCharacters.Add(lang, varToCheck.value); } myNPMCharacter.presCharacters = myPresCharacters; myNPMCharacter.presTexts = myPresTexts; myNPMCharacters.Add(myNPMCharacter); varToCheck.npmRef = myNPMCharacter.id; cat3Counter++; npmId++; } else { throw new PCAxis.Sql.Exceptions.DbException(24); } } else { // throw new PCAxis.Sql.Exceptions.DbException(25, dataSymbolSum); } } }
private void setNpmCharacters() { Dictionary <string, SpecialCharacterRow> specialCharacterRows = new Dictionary <string, SpecialCharacterRow>(); specialCharacterRows = mMeta.MetaQuery.GetSpecialCharacterAllRows(); NPMCharacter myNPMCharacter; npmId = 0; //myNPMCharacters = new Dictionary<int,NPMCharacter>(); myNPMCharacters = new List <NPMCharacter>(); foreach (KeyValuePair <string, SpecialCharacterRow> myRow in specialCharacterRows) { myNPMCharacter = new NPMCharacter(); myNPMCharacter.id = npmId; myNPMCharacter.characterType = myRow.Value.CharacterType; myNPMCharacter.presCharacters = new Dictionary <string, string>(); myNPMCharacter.presTexts = new Dictionary <string, string>(); foreach (string lang in mMeta.LanguageCodes) { myNPMCharacter.presCharacters[lang] = myRow.Value.texts[lang].PresCharacter; myNPMCharacter.presTexts[lang] = myRow.Value.texts[lang].PresText; } if (myRow.Value.DataCellPres == mMeta.Config.Codes.Yes && myRow.Value.AggregPossible == mMeta.Config.Codes.Yes) { myNPMCharacter.category = 1; } else if (myRow.Value.DataCellPres == mMeta.Config.Codes.No && myRow.Value.AggregPossible == mMeta.Config.Codes.Yes) { myNPMCharacter.category = 2; } else if (myRow.Value.DataCellPres == mMeta.Config.Codes.No && myRow.Value.AggregPossible == mMeta.Config.Codes.No) { myNPMCharacter.category = 3; } // Category 1 if (myNPMCharacter.category == 1) { cat1Counter++; } // category 2 else if (myNPMCharacter.category == 2) { myNPMCharacter.pcAxisCode = PcAxisCodes.DataSymbol_NIL; cat2Counter++; if (cat2Counter > 1) { throw new PCAxis.Sql.Exceptions.DbException(15); } } // category 3 else if (myNPMCharacter.category == 3) { // check to se if any of the character is the same as the one specified for DataSymbolSum. if ((metaVersion == "2.1" && (myNPMCharacter.presCharacters[mMeta.LanguageCodes[0]] == myMetaAdmVariables[dataSymbolSum].value)) || ((metaVersion == "2.2") && (myNPMCharacter.characterType == myMetaAdmVariables[dataSymbolSum].value))) { myNPMCharacter.pcAxisCode = PcAxisCodes.DataSymbol_Sum; dataSymbolSumNpmId = npmId; dataNoteSumSet = true; } else { cat3Counter++; if (cat3Counter > 6) { throw new PCAxis.Sql.Exceptions.DbException(16); } else { myNPMCharacter.dataSymbolNr = cat3Counter; myNPMCharacter.pcAxisCode = PcAxisCodes.getDataSymbolNo(cat3Counter); } } } else { throw new PCAxis.Sql.Exceptions.DbException(17); } // myNPMCharacters.Add(npmId, myNPMCharacter); myNPMCharacters.Add(myNPMCharacter); npmId++; } }