[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/office/tellico
From:       Robby Stephenson <robby () periapsis ! org>
Date:       2010-08-29 22:49:58
Message-ID: 20100829224958.58614AC86C () svn ! kde ! org
[Download RAW message or body]

SVN commit 1169716 by rstephenson:

improve gcstar import/export for coin collection

 A             src/tests/data/test-coin.gcs  
 M  +47 -1     src/tests/gcstartest.cpp  
 M  +3 -2      src/tests/gcstartest.h  
 M  +32 -5     xslt/gcstar2tellico.xsl  
 M  +39 -10    xslt/tellico2gcstar.xsl  


--- trunk/extragear/office/tellico/src/tests/gcstartest.cpp #1169715:1169716
@@ -38,6 +38,7 @@
 #include <kstandarddirs.h>
 
 #define FIELDS(entry, fieldName) \
Tellico::FieldFormat::splitValue(entry->field(fieldName)) +#define TABLES(entry, \
fieldName) Tellico::FieldFormat::splitTable(entry->field(fieldName))  
 QTEST_KDEMAIN_CORE( GCstarTest )
 
@@ -354,7 +355,6 @@
   }
 }
 
-
 void GCstarTest::testWine() {
   KUrl url(QString::fromLatin1(KDESRCDIR) + "/data/test-wine.gcs");
   Tellico::Import::GCstarImporter importer(url);
@@ -407,3 +407,49 @@
     }
   }
 }
+
+void GCstarTest::testCoin() {
+  KUrl url(QString::fromLatin1(KDESRCDIR) + "/data/test-coin.gcs");
+  Tellico::Import::GCstarImporter importer(url);
+  Tellico::Data::CollPtr coll = importer.collection();
+
+  QVERIFY(!coll.isNull());
+  QCOMPARE(coll->type(), Tellico::Data::Collection::Coin);
+  QCOMPARE(coll->entryCount(), 1);
+
+  Tellico::Data::EntryPtr entry = coll->entryById(1);
+  QVERIFY(!entry.isNull());
+  QCOMPARE(entry->field("denomination"), QLatin1String("0.05"));
+  QCOMPARE(entry->field("year"), QLatin1String("1974"));
+  QCOMPARE(entry->field("currency"), QLatin1String("USD"));
+  QCOMPARE(entry->field("diameter"), QLatin1String("12.7"));
+  QCOMPARE(entry->field("estimate"), QLatin1String("5"));
+  QCOMPARE(entry->field("grade"), QLatin1String("Mint State-65"));
+  QCOMPARE(entry->field("country"), QLatin1String("australia"));
+  QCOMPARE(entry->field("location"), QLatin1String("current"));
+  QCOMPARE(entry->field("service"), QLatin1String("PCGS"));
+  QCOMPARE(TABLES(entry, "metal").count(), 2);
+  QCOMPARE(TABLES(entry, "metal").at(1), QLatin1String("metal2"));
+  QVERIFY(!entry->field("comments").isEmpty());
+
+  Tellico::Export::GCstarExporter exporter(coll);
+  exporter.setEntries(coll->entries());
+  Tellico::Import::GCstarImporter importer2(exporter.text());
+  Tellico::Data::CollPtr coll2 = importer2.collection();
+
+  QVERIFY(!coll2.isNull());
+  QCOMPARE(coll2->type(), coll->type());
+  QCOMPARE(coll2->entryCount(), coll->entryCount());
+  QCOMPARE(coll2->title(), coll->title());
+
+  foreach(Tellico::Data::EntryPtr e1, coll->entries()) {
+    Tellico::Data::EntryPtr e2 = coll2->entryById(e1->id());
+    QVERIFY(e2);
+    foreach(Tellico::Data::FieldPtr f, coll->fields()) {
+      // skip images
+      if(f->type() != Tellico::Data::Field::Image) {
+        QCOMPARE(f->name() + e2->field(f), f->name() + e1->field(f));
+      }
+    }
+  }
+}
--- trunk/extragear/office/tellico/src/tests/gcstartest.h #1169715:1169716
@@ -32,12 +32,13 @@
 
 private Q_SLOTS:
   void initTestCase();
+  void testBoardGame();
   void testBook();
+  void testCoin();
   void testComicBook();
-  void testVideo();
   void testMusic();
   void testVideoGame();
-  void testBoardGame();
+  void testVideo();
   void testWine();
 };
 
--- trunk/extragear/office/tellico/xslt/gcstar2tellico.xsl #1169715:1169716
@@ -65,7 +65,7 @@
    <xsl:if test="item/@web or item/@webPage">
     <tc:field flags="0" title="URL" category="General" format="4" type="7" \
name="url" i18n="true"/>  </xsl:if>
-   <xsl:if test="item/@location and $coll != 7">
+   <xsl:if test="item/@location and $coll != 7 and $coll != 8">
      <tc:field flags="6" title="Location" category="Personal" format="4" type="1" \
name="location" i18n="true"/>  </xsl:if>
    <xsl:if test="item/@composer">
@@ -83,6 +83,15 @@
      <!-- gcstar includes way more coin grades than tellico -->
      <tc:field flags="2" title="Grade" category="General" format="4" type="3" \
name="grade"  allowed="Proof-65;Proof-60;Mint State-70;Mint State-69;Mint \
State-68;Mint State-67;Mint State-66;Mint State-65;Mint State-64;Mint State-63;Mint \
State-62;Mint State-61;Mint State-60;Almost Uncirculated-58;Almost \
Uncirculated-55;Almost Uncirculated-53;Almost Uncirculated-50;Extremely \
Fine-45;Extremely Fine-40;Very Fine-35;Very Fine-30;Very Fine-25;Very \
Fine-20;Fine-15;Fine-12;Very Good-10;Very Good-8;Good-6;Good-4;Fair"/> +     \
<tc:field flags="6" title="Diameter" category="General" format="4" type="1" \
name="diameter" i18n="true"/> +     <tc:field flags="0" title="Estimate" \
category="Personal" format="4" type="1" name="estimate" i18n="true"/> +     <xsl:if \
test="item/metal"> +      <tc:field title="Composition" flags="3" \
category="Composition" format="2" type="8" name="metal"> +       <tc:prop \
name="column1">Metal</tc:prop> +       <tc:prop name="column2">Percentage</tc:prop>
+       <tc:prop name="columns">2</tc:prop>
+      </tc:field>
+     </xsl:if>
     </xsl:when>
     <xsl:when test="@type='GCwines'">
      <tc:field title="Varietal" flags="7" category="General" format="0" type="1" \
name="varietal" i18n="true"/> @@ -144,7 +153,7 @@
 <xsl:template match="*"/>
 
 <!-- the easy one matches identical local names -->
-<xsl:template match="title|isbn|edition|pages|label|platform|location|vintage|quantity|soil|alcohol|collection|series">
 +<xsl:template match="title|isbn|edition|pages|label|platform|location|vintage|quantity|soil|alcohol|collection|series|currency|diameter|estimate">
  <xsl:element name="{concat('tc:',local-name())}">
   <xsl:value-of select="."/>
  </xsl:element>
@@ -516,15 +525,23 @@
  </tc:subtitles>
 </xsl:template>
 
-<xsl:template match="currency">
- <tc:type><xsl:value-of select="."/></tc:type>
+<xsl:template match="metal">
+ <tc:metals>
+  <xsl:for-each select="line">
+   <tc:metal>
+    <tc:column>
+     <xsl:value-of select="col[1]"/>
+    </tc:column>
+   </tc:metal>
+  </xsl:for-each>
+ </tc:metals>
 </xsl:template>
 
 <xsl:template match="value">
  <tc:denomination><xsl:value-of select="."/></tc:denomination>
 </xsl:template>
 
-<xsl:template match="estimate|purchaseprice|cost">
+<xsl:template match="purchaseprice|cost">
  <tc:pur_price><xsl:value-of select="."/></tc:pur_price>
 </xsl:template>
 
@@ -622,6 +639,8 @@
    <xsl:when test=".&lt;4">Fair</xsl:when>
   </xsl:choose>
  </tc:grade>
+ <!-- GCstar defaults to PCGS -->
+ <tc:service>PCGS</tc:service>
 </xsl:template>
 
 <xsl:template match="designation">
@@ -665,6 +684,14 @@
  </xsl:if>
 </xsl:template>
 
+<xsl:template match="front">
+ <tc:obverse><xsl:value-of select="."/></tc:obverse>
+</xsl:template>
+
+<xsl:template match="back">
+ <tc:reverse><xsl:value-of select="."/></tc:reverse>
+</xsl:template>
+
 <xsl:template name="year">
  <xsl:param name="value"/>
  <!-- want to find a 4-digit number to treat as the year -->
--- trunk/extragear/office/tellico/xslt/tellico2gcstar.xsl #1169715:1169716
@@ -24,7 +24,8 @@
 <!-- bool attributes are special, and some only apply to certain collection types \
-->  <a:attributes>
  <a:attribute name="isbn">isbn</a:attribute>
-  <a:attribute name="title">title</a:attribute>
+  <!-- titles for coins and wines are templated -->
+  <a:attribute name="title" skip="GCcoins, GCwines">title</a:attribute>
   <a:attribute name="publisher" skip="GCboardgames">publisher</a:attribute>
   <a:attribute name="publishedby" type="GCboardgames">publisher</a:attribute>
   <a:attribute name="publication">pub_year</a:attribute>
@@ -51,7 +52,7 @@
   <a:attribute name="seen" format="bool" type="GCfilms">seen</a:attribute>
   <a:attribute name="favourite" format="bool">favorite</a:attribute>
   <a:attribute name="label">label</a:attribute>
-  <a:attribute name="release">year</a:attribute>
+  <a:attribute name="release" type="GCfilms">year</a:attribute>
   <a:attribute name="composer">composer</a:attribute>
   <a:attribute name="producer">producer</a:attribute>
   <a:attribute name="platform">platform</a:attribute>
@@ -69,7 +70,6 @@
   <a:attribute name="volume" skip="GCcomics">volume</a:attribute>
   <a:attribute name="volume" type="GCcomics">issue</a:attribute>
   <a:attribute name="tasting">description</a:attribute>
-  <a:attribute name="comments">comments</a:attribute>
   <a:attribute name="medal">distinction</a:attribute>
   <a:attribute name="tasted" format="bool" type="GCwines">tasted</a:attribute>
   <a:attribute name="gift" format="bool">gift</a:attribute>
@@ -79,6 +79,10 @@
   <a:attribute name="collection">collection</a:attribute>
   <a:attribute name="numberboards">numberboards</a:attribute>
   <a:attribute name="signing" format="bool">signed</a:attribute>
+  <a:attribute name="estimate">estimate</a:attribute>
+  <a:attribute name="currency">currency</a:attribute>
+  <a:attribute name="diameter">diameter</a:attribute>
+  <a:attribute name="value">denomination</a:attribute>
 </a:attributes>
 <xsl:variable name="collType">
  <xsl:choose>
@@ -153,7 +157,12 @@
 
 <xsl:template match="tc:entry">
  <xsl:variable name="entry" select="."/>
- <item id="{@id}" rating="{tc:rating * 2}">
+ <item id="{@id}">
+  <xsl:if test="tc:rating">
+   <xsl:attribute name="rating">
+    <xsl:value-of select="2*tc:rating"/>
+   </xsl:attribute>
+  </xsl:if>
   <xsl:for-each select="$attributes">
    <xsl:call-template name="handle-attribute">
     <xsl:with-param name="att" select="."/>
@@ -221,11 +230,6 @@
     <xsl:with-param name="elem" select="tc:keywords"/>
    </xsl:call-template>
   </tags>
-  <xsl:if test="$collType  = 'GCbooks'">
-   <comments>
-    <xsl:value-of select="tc:comments"/>
-   </comments>
-  </xsl:if>
 
   <!-- for movies -->
   <synopsis>
@@ -248,10 +252,20 @@
     <xsl:with-param name="elem" select="tc:subtitles"/>
    </xsl:call-template>
   </subt>
-  <xsl:if test="$collType  = 'GCfilms' or $collType = 'GCboardgames'">
+  <xsl:choose>
+   <xsl:when test="$collType = 'GCfilms' or $collType = 'GCboardgames'">
    <comment> <!-- note the lack of an 's' -->
     <xsl:value-of select="tc:comments"/>
    </comment>
+   </xsl:when>
+   <xsl:otherwise>
+    <comments>
+     <xsl:value-of select="tc:comments"/>
+    </comments>
+   </xsl:otherwise>
+  </xsl:choose>
+
+  <xsl:if test="$collType = 'GCfilms'">
    <xsl:apply-templates select="tc:languages"/>
   </xsl:if>
 
@@ -277,6 +291,9 @@
    </xsl:call-template>
   </grapes>
 
+  <!-- for coins -->
+  <xsl:apply-templates select="tc:metals"/>
+
  </item>
 </xsl:template>
 
@@ -314,6 +331,18 @@
  </tracks>
 </xsl:template>
 
+<xsl:template match="tc:metals">
+ <metal>
+  <xsl:for-each select="tc:metal">
+   <line>
+    <col>
+     <xsl:value-of select="tc:column[1]"/>
+    </col>
+   </line>
+  </xsl:for-each>
+ </metal>
+</xsl:template>
+
 <xsl:template name="multiline">
  <xsl:param name="elem"/>
  <xsl:for-each select="$elem/child::*">


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic