コード例 #1
0
/** 
 * Test Case required for INC078981 "Contacts model field type mathching urgent fix"   
 */
LOCAL_C void TestTemplateFieldTypeMatchingL()
	{
	test.Next(_L("Create template"));
	CreateDatabaseL();
	CContactDatabase* db=CntTest->OpenDatabaseL();
	CntTest->DeleteAllTemplateFieldsL();

	_LIT(KField1,"Field 1");

	CContactTemplate *contactTemplate=(CContactTemplate *)db->OpenContactLX(db->TemplateId());
	CleanupStack::PushL(contactTemplate);
	TFieldType mapping1(TUid::Uid(KIntContactFieldVCardMapSIPID));
	TFieldType mappingX(TUid::Uid(KIntContactFieldVCardMapSIPID));
	TFieldType mapping2(TUid::Uid(KIntContactFieldVCardMapVOIP));
	TFieldType mapping3(TUid::Uid(3));
	TFieldType mapping4(TUid::Uid(4));
	TFieldType fieldType1(TUid::Uid(KUidContactFieldSIPIDValue));
	TFieldType fieldType2(TUid::Uid(KIntContactFieldVCardMapVOIP));

	AddFieldL(contactTemplate,mapping1,KField1(),&fieldType1,&mappingX);

	AddFieldL(contactTemplate,mapping1,KField1(),&fieldType1,&mapping2);
	AddFieldL(contactTemplate,mapping1,KField1(),&fieldType1,&mapping3);
	AddFieldL(contactTemplate,mapping1,KField1(),&fieldType1,&mapping4);
	
	db->CommitContactL(*contactTemplate);

	CleanupStack::PopAndDestroy(); // contactTemplate
	CleanupStack::Pop(); // contactTemplate.Close()

	TTemplateMapTest tmTest1(mapping1,&fieldType1,&mappingX,NULL,KField1(),1,ETrue);
	TTemplateMapTest tmTest2(mapping1,&fieldType1,&mapping2,NULL,KField1(),2,ETrue);
	TTemplateMapTest tmTest3(mapping1,&fieldType1,&mapping3,NULL,KField1(),3,ETrue);
	TTemplateMapTest tmTest4(mapping1,&fieldType1,&mapping4,NULL,KField1(),4,ETrue);
	TTemplateMapTest tmTest5(mapping1,&fieldType2,&mappingX,NULL,KField1(),1,EFalse);

	contactTemplate=(CContactTemplate *)ReadContactIncHiddenFieldsLC(db,db->TemplateId());
	CheckFieldMappings(db,contactTemplate,&tmTest1);
	CheckFieldMappings(db,contactTemplate,&tmTest3);
	CheckFieldMappings(db,contactTemplate,&tmTest2);
	CheckFieldMappings(db,contactTemplate,&tmTest4);
	CheckFieldMappings(db,contactTemplate,&tmTest5);

	CleanupStack::PopAndDestroy(); // contactTemplate
	CntTest->CloseDatabase();
	}
コード例 #2
0
CheckParallelPassages::CheckParallelPassages(bool nt, const ustring & project, const vector < unsigned int >&books, bool includetext, bool gui,const ustring & project2)
{
  // Language.
  extern Settings *settings;
  ustring language = settings->projectconfig(project, false)->language_get();

  // Mapping.
  ustring versification = settings->projectconfig(project, false)->versification_get();
  Mapping mapping(versification, 0);

  // Get a list of the books to check. If no books were given, take them all.
  vector < unsigned int >mybooks(books.begin(), books.end());
  if (mybooks.empty())
    mybooks = project_get_books(project);
  set < unsigned int >bookset(mybooks.begin(), mybooks.end());

  // Get the parallel passages.
  OtNtParallels otntparallels(0);
  if (nt)
    otntparallels.readnt();
  else
    otntparallels.readot();

  // GUI.
  progresswindow = NULL;
  if (gui) {
    progresswindow = new ProgressWindow(_("Producing passages"), true);
    progresswindow->set_iterate(0, 1, otntparallels.sections.size());
  }
  // Go through each section.
  for (unsigned int i = 0; i < otntparallels.sections.size(); i++) {
    if (gui) {
      progresswindow->iterate();
      if (progresswindow->cancel)
        return;
    }
    OtNtParallelDataSection datasection(0);
    // Section's heading.
    datasection.title = otntparallels.sections[i].title;
    // Go through each set of references.
    for (unsigned int i2 = 0; i2 < otntparallels.sections[i].sets.size(); i2++) {
      // Go through the references in the set.
      OtNtParallelDataSet dataset(0);
      for (unsigned int i3 = 0; i3 < otntparallels.sections[i].sets[i2].references.size(); i3++) {
        // Skip if NT book is not to be included.
        if (bookset.find(otntparallels.sections[i].sets[i2].references[i3].book) == bookset.end())
          continue;
        vector < int >remapped_chapter;
        vector < int >remapped_verse;
        mapping.book_change(otntparallels.sections[i].sets[i2].references[i3].book);
        mapping.original_to_me(otntparallels.sections[i].sets[i2].references[i3].chapter, otntparallels.sections[i].sets[i2].references[i3].verse, remapped_chapter, remapped_verse);
        Reference mapped_reference(otntparallels.sections[i].sets[i2].references[i3].book, remapped_chapter[0], convert_to_string(remapped_verse[0]));
        ustring verse = mapped_reference.human_readable(language);
        if (includetext) {
          verse.append(" ");
          verse.append(usfm_get_verse_text_only(project_retrieve_verse(project, mapped_reference.book, mapped_reference.chapter, mapped_reference.verse)));
        }
        dataset.data.push_back(verse);
        references.push_back(books_id_to_english(mapped_reference.book) + " " + convert_to_string(mapped_reference.chapter) + ":" + mapped_reference.verse);
        comments.push_back(_("Parallel"));
      }

      datasection.sets.push_back(dataset);
      //output verses of second project
      OtNtParallelDataSet dataset2(0);
      //TODO refactor this loop into a separate function
      if (project2!="")
      {
    	  ustring language2 = settings->projectconfig(project2, false)->language_get();

    	  // Mapping.
    	  ustring versification2 = settings->projectconfig(project2, false)->versification_get();
    	  Mapping mapping2(versification2, 0);

    	  for (unsigned int i3 = 0; i3 < otntparallels.sections[i].sets[i2].references.size(); i3++) {
    		  // Skip if NT book is not to be included.
    		  if (bookset.find(otntparallels.sections[i].sets[i2].references[i3].book) == bookset.end())
    			  continue;
    		  vector < int >remapped_chapter;
    		  vector < int >remapped_verse;
    		  mapping2.book_change(otntparallels.sections[i].sets[i2].references[i3].book);
    		  mapping2.original_to_me(otntparallels.sections[i].sets[i2].references[i3].chapter, otntparallels.sections[i].sets[i2].references[i3].verse, remapped_chapter, remapped_verse);
    		  Reference mapped_reference(otntparallels.sections[i].sets[i2].references[i3].book, remapped_chapter[0], convert_to_string(remapped_verse[0]));
    		  ustring verse = mapped_reference.human_readable(language);
    		  if (includetext) {
    			  verse.append(" ");
    			  verse.append(usfm_get_verse_text_only(project_retrieve_verse(project2, mapped_reference.book, mapped_reference.chapter, mapped_reference.verse)));
    		  }
    		  dataset2.data.push_back(verse);
    		  references.push_back(books_id_to_english(mapped_reference.book) + " " + convert_to_string(mapped_reference.chapter) + ":" + mapped_reference.verse);
    		  comments.push_back(_("Parallel"));
    	  }
      	  datasection.sets.push_back(dataset2);
      }

    }
    data.push_back(datasection);
  }
}
コード例 #3
0
LOCAL_C void TestTemplateFieldMatchingL()
	{
	test.Next(_L("Create template"));
	CreateDatabaseL();
	CContactDatabase* db=CntTest->OpenDatabaseL();
	CntTest->DeleteAllTemplateFieldsL();
//
	_LIT(KField1,"Field 1");
	_LIT(KField2,"Field 2");
	_LIT(KField3,"Field 3");
	_LIT(KField4,"Field 4");
	_LIT(KField5,"Field 5");
	_LIT(KField6,"Field 6");
	_LIT(KField7,"Field 7");
	_LIT(KField8,"Field 8");
	_LIT(KField9,"Field 9");
	_LIT(KFieldX1,"Field X1");
	_LIT(KFieldX2,"Field X2");
	_LIT(KFieldHome,"Field Home");
	_LIT(KFieldWork,"Field Work");
//
	CContactTemplate *contactTemplate=(CContactTemplate *)db->OpenContactLX(db->TemplateId());
	CleanupStack::PushL(contactTemplate);
	TFieldType mapping1(TUid::Uid(1));
	TFieldType mapping2(TUid::Uid(2));
	TFieldType mapping3(TUid::Uid(3));
	TFieldType mapping4(TUid::Uid(4));
	TFieldType mappingX(KUidContactFieldVCardMapUnusedN);
	TFieldType fieldType1(TUid::Uid(101));
	TFieldType fieldType2(TUid::Uid(102));
	TFieldType fieldType3(TUid::Uid(103));
	TFieldType fieldType4(TUid::Uid(104));
	TFieldType fieldType5(TUid::Uid(105));
	TFieldType fieldTypeHome(TUid::Uid(KIntContactFieldVCardMapHOME));
	TFieldType fieldTypeWork(TUid::Uid(KIntContactFieldVCardMapWORK));
	AddFieldL(contactTemplate,mapping1,KField1());
	SetUserFlags(contactTemplate,1);
	AddFieldL(contactTemplate,mapping2,KField2(),&fieldType2);
	SetUserFlags(contactTemplate,2);
	AddFieldL(contactTemplate,mapping2,KField3(),&fieldType3);
	SetUserFlags(contactTemplate,3);
	AddFieldL(contactTemplate,mapping3,KField4(),&fieldType2);
	SetUserFlags(contactTemplate,0);
	AddFieldL(contactTemplate,mapping3,KField5(),&fieldType2,&fieldType4);
	SetUserFlags(contactTemplate,1);
	AddFieldL(contactTemplate,mapping3,KField6(),&fieldType2,&fieldType1);
	SetUserFlags(contactTemplate,2);
	AddFieldL(contactTemplate,mapping4,KField8(),&fieldType4);
	SetUserFlags(contactTemplate,3);
	InsertFieldL(contactTemplate,mapping4,6,KField7());
	SetUserFlags(contactTemplate,0);
	AddFieldL(contactTemplate,mapping4,KField9(),&fieldType4,&fieldType2,&fieldType1);
	SetUserFlags(contactTemplate,1);
	AddFieldL(contactTemplate,mappingX,KFieldX1());
	SetUserFlags(contactTemplate,2);
	AddFieldL(contactTemplate,mappingX,KFieldX2(),&fieldType2);
	SetUserFlags(contactTemplate,3);
	AddFieldL(contactTemplate,mapping1,KFieldHome(),&fieldType1,&fieldType5,&fieldTypeHome);
	SetUserFlags(contactTemplate,0);
	AddFieldL(contactTemplate,mapping1,KFieldWork(),&fieldType1,&fieldType5,&fieldTypeWork);
	
	SetUserFlags(contactTemplate,0);
	db->CommitContactL(*contactTemplate);
	CleanupStack::PopAndDestroy(); // contactTemplate
	CleanupStack::Pop(); // contactTemplate.Close()
//
	TTemplateMapTest tmTest1(mapping1,&fieldType4,NULL,NULL,KField1(),1,EFalse);
	TTemplateMapTest tmTest2(mapping2,&fieldType1,NULL,NULL,KField2(),2,EFalse);
	TTemplateMapTest tmTest3(mapping2,&fieldType2,NULL,NULL,KField2(),2,ETrue);
	TTemplateMapTest tmTest4(mapping2,&fieldType3,NULL,NULL,KField3(),3,ETrue);
	TTemplateMapTest tmTest5(mapping3,&fieldType4,NULL,NULL,KField5(),5,EFalse);
	TTemplateMapTest tmTest6(mapping3,&fieldType1,NULL,NULL,KField6(),6,EFalse);
	TTemplateMapTest tmTest7(mapping3,&fieldType2,&fieldType4,NULL,KField5(),5,ETrue);
	TTemplateMapTest tmTest8(mapping4,&fieldType3,NULL,NULL,KField7(),7,EFalse);
	TTemplateMapTest tmTest9(mapping4,&fieldType4,NULL,NULL,KField8(),8,ETrue);
	TTemplateMapTest tmTest10(mapping4,&fieldType4,&fieldType2,NULL,KField9(),9,EFalse);
	TTemplateMapTest tmTestX1(mappingX,&fieldType4,NULL,NULL,KFieldX1(),10,EFalse,&mappingX);
	TTemplateMapTest tmTestX2(mappingX,&fieldType2,NULL,NULL,KFieldX2(),11,ETrue);
	TTemplateMapTest tmTestWork(mapping1,&fieldType1,&fieldType5,NULL,KFieldWork(),13,EFalse,NULL,&fieldTypeWork);//zzz change to work
	contactTemplate=(CContactTemplate *)ReadContactIncHiddenFieldsLC(db,db->TemplateId());
	CheckFieldMappings(db,contactTemplate,&tmTest1);
	CheckFieldMappings(db,contactTemplate,&tmTest1,&tmTest3,&tmTest4);
	CheckFieldMappings(db,contactTemplate,&tmTest5,&tmTest2,&tmTest1,&tmTest6);
	CheckFieldMappings(db,contactTemplate,&tmTest7,&tmTest10,&tmTest8);
	CheckFieldMappings(db,contactTemplate,&tmTest9);
	CheckFieldMappings(db,contactTemplate,&tmTestX1);
	CheckFieldMappings(db,contactTemplate,&tmTestX2);
	CheckFieldMappings(db,contactTemplate,&tmTestWork);
//
	CleanupStack::PopAndDestroy(); // contactTemplate
	CntTest->CloseDatabase();
	}
コード例 #4
0
CheckParallelPassages::CheckParallelPassages(bool nt, const ustring & project, const vector < unsigned int >&books, bool includetext, bool gui,const ustring & project2)
{
  // Language.
  extern Settings *settings;
  ustring language = settings->projectconfig(project, false)->language_get();

  // Mapping.
  ustring versification = settings->projectconfig(project, false)->versification_get();
  Mapping mapping(versification, 0);

  // Get a list of the books to check. If no books were given, take them all.
  vector < unsigned int >mybooks(books.begin(), books.end());
  if (mybooks.empty()) {
    mybooks = project_get_books(project);
  }
  set < unsigned int >bookset(mybooks.begin(), mybooks.end());

  // Get the parallel passages.
  OtNtParallels otntparallels(0);
  if (nt) {
    otntparallels.readnt();
  }
  else {
    otntparallels.readot();
  }

  // GUI.
  progresswindow = NULL;
  if (gui) {
    progresswindow = new ProgressWindow(_("Producing passages"), true);
    progresswindow->set_iterate(0, 1, otntparallels.sections.size());
  }
  // Go through each section.
  for (unsigned int i = 0; i < otntparallels.sections.size(); i++) {
    if (gui) {
      progresswindow->iterate();
      if (progresswindow->cancel)
        return;
    }
    OtNtParallelDataSection datasection(0);
    // Section's heading.
    datasection.title = otntparallels.sections[i].title;
    // Go through each set of references.
    for (unsigned int i2 = 0; i2 < otntparallels.sections[i].sets.size(); i2++) {
      // Go through the references in the set.
      OtNtParallelDataSet dataset(0);
      for (unsigned int i3 = 0; i3 < otntparallels.sections[i].sets[i2].references.size(); i3++) {
        // Skip if NT book is not to be included.
        if (bookset.find(otntparallels.sections[i].sets[i2].references[i3].book_get()) == bookset.end()) {
          continue;
	}
        vector < int >remapped_chapter;
        vector < int >remapped_verse;
        mapping.book_change(otntparallels.sections[i].sets[i2].references[i3].book_get());
        mapping.original_to_me(otntparallels.sections[i].sets[i2].references[i3].chapter_get(), otntparallels.sections[i].sets[i2].references[i3].verse_get(), remapped_chapter, remapped_verse);
	ustring verse;

	// The verse can have a range, like Matthew 3:1-2, and we have to handle all verses in that range.
	// Prior to 5/23/2016, all that was used was remapped_verse[0], which destroyed any other verses in the range.
	for (unsigned int i4 = 0; i4 < remapped_verse.size(); i4++) {
	  Reference mapped_reference(otntparallels.sections[i].sets[i2].references[i3].book_get(), remapped_chapter[0], convert_to_string(remapped_verse[i4]));
	  if (i4 > 0) {
	    // For the second verse and beyond, we need to put an extra space and handle the verse number specially.
	    verse.append(" [" + mapped_reference.verse_get() + "]");
	  }
	  else {
	    verse.append(mapped_reference.human_readable(language));
	  }
	  if (includetext) {
	    verse.append(" ");
	    verse.append(usfm_get_verse_text_only(project_retrieve_verse(project, mapped_reference.book_get(), mapped_reference.chapter_get(), mapped_reference.verse_get())));
	  }
	}

        dataset.data.push_back(verse);
	//        references.push_back(books_id_to_localname(mapped_reference.book_get()) + " " + convert_to_string(mapped_reference.chapter_get()) + ":" + mapped_reference.verse_get());
        references.push_back(books_id_to_localname(otntparallels.sections[i].sets[i2].references[i3].book_get()) + " "
			     + convert_to_string(otntparallels.sections[i].sets[i2].references[i3].chapter_get()) + ":"
			     + otntparallels.sections[i].sets[i2].references[i3].verse_get());
        comments.push_back(_("Parallel"));
      }

      datasection.sets.push_back(dataset);
      //output verses of second project
      OtNtParallelDataSet dataset2(0);
      //TODO refactor this loop into a separate function
      if (project2!="")
      {
    	  ustring language2 = settings->projectconfig(project2, false)->language_get();

    	  // Mapping.
    	  ustring versification2 = settings->projectconfig(project2, false)->versification_get();
    	  Mapping mapping2(versification2, 0);

    	  for (unsigned int i3 = 0; i3 < otntparallels.sections[i].sets[i2].references.size(); i3++) {
    		  // Skip if NT book is not to be included.
	    if (bookset.find(otntparallels.sections[i].sets[i2].references[i3].book_get()) == bookset.end())
    			  continue;
    		  vector < int >remapped_chapter;
    		  vector < int >remapped_verse;
    		  mapping2.book_change(otntparallels.sections[i].sets[i2].references[i3].book_get());
    		  mapping2.original_to_me(otntparallels.sections[i].sets[i2].references[i3].chapter_get(), otntparallels.sections[i].sets[i2].references[i3].verse_get(), remapped_chapter, remapped_verse);
    		  Reference mapped_reference(otntparallels.sections[i].sets[i2].references[i3].book_get(), remapped_chapter[0], convert_to_string(remapped_verse[0]));
    		  ustring verse = mapped_reference.human_readable(language);
    		  if (includetext) {
    			  verse.append(" ");
    			  verse.append(usfm_get_verse_text_only(project_retrieve_verse(project2, mapped_reference.book_get(), mapped_reference.chapter_get(), mapped_reference.verse_get())));
    		  }
    		  dataset2.data.push_back(verse);
    		  references.push_back(books_id_to_localname(mapped_reference.book_get()) + " " + convert_to_string(mapped_reference.chapter_get()) + ":" + mapped_reference.verse_get());
    		  comments.push_back(_("Parallel"));
    	  }
      	  datasection.sets.push_back(dataset2);
      }

    }
    data.push_back(datasection);
  }
}