added "tab" attribute to the MetadataType class

This commit is contained in:
fgerlits 2005-09-05 19:38:41 +00:00
parent 5b1e360139
commit a499b508f3
5 changed files with 79 additions and 9 deletions

View file

@ -5,11 +5,13 @@
<!ATTLIST metadataType dcName NMTOKEN #REQUIRED >
<!ATTLIST metadataType id3Tag NMTOKEN #IMPLIED >
<!ATTLIST metadataType localizationKey NMTOKEN #REQUIRED >
<!ATTLIST metadataType tab NMTOKEN #IMPLIED >
]>
<metadataType dcName = "dc:creator"
id3Tag = "TPE2"
localizationKey = "creator"
tab = "main"
/>

View file

@ -5,6 +5,7 @@
<!ATTLIST metadataType dcName NMTOKEN #REQUIRED >
<!ATTLIST metadataType id3Tag CDATA #IMPLIED >
<!ATTLIST metadataType localizationKey CDATA #REQUIRED >
<!ATTLIST metadataType tab NMTOKEN #IMPLIED >
<!ELEMENT metadataTypeContainer (metadataType+) >
@ -14,6 +15,7 @@
<metadataType dcName = "dc:title"
id3Tag = "TIT2"
localizationKey = "title"
tab = "main"
/>
<metadataType dcName = "dc:creator"
id3Tag = "TPE1"

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/MetadataType.h,v $
------------------------------------------------------------------------------*/
@ -71,9 +71,16 @@ class MetadataTypeContainer;
* <metadataType dcName = "dc:creator"
* id3Tag = "TPE2"
* localizationKey = "dc_creator"
* tab = "main"
* />
* </code></pre>
*
* The tab attribute (if present) must be one of "main", "music" or "talk"
* (all lowercase, case sensitive).
* This determines whether, at file upload, the metadata field appears in
* the Main, Music, or Talk tab. If the attribute is omitted, the metadata
* field will appear in none of the tabs.
*
* The DTD for the expected XML element looks like the following:
*
* <pre><code>
@ -81,17 +88,28 @@ class MetadataTypeContainer;
* <!ATTLIST metadataType dcName NMTOKEN #REQUIRED >
* <!ATTLIST metadataType id3Tag NMTOKEN #IMPLIED >
* <!ATTLIST metadataType localizationKey NMTOKEN #REQUIRED >
* <!ATTLIST metadataType tab NMTOKEN #IMPLIED >
* </code></pre>
*
*
* @author $Author: fgerlits $
* @version $Revision: 1.3 $
* @version $Revision: 1.4 $
* @see MetadataTypeContainer
*/
class MetadataType : public Configurable
{
friend class MetadataTypeContainer;
public:
/**
* An enumeration of all possible metadata categories.
*/
typedef enum { noTab,
mainTab,
musicTab,
talkTab } TabType;
private:
/**
* The name of the configuration XML element used by MetadataType.
@ -118,6 +136,11 @@ class MetadataType : public Configurable
*/
Ptr<Glib::ustring>::Ref localizationKey;
/**
* The localization key for this metadata type.
*/
TabType tab;
protected:
/**
@ -140,7 +163,8 @@ class MetadataType : public Configurable
MetadataType(Ptr<MetadataTypeContainer>::Ref container,
Glib::ustring dcName,
Glib::ustring id3Tag,
Glib::ustring localizationKey)
Glib::ustring localizationKey,
TabType tab = noTab)
throw ();
/**
@ -219,6 +243,18 @@ class MetadataType : public Configurable
*/
Ptr<const Glib::ustring>::Ref
getLocalizedName(void) const throw (std::invalid_argument);
/**
* Return the tab that this metadata type should appear in,
* when an audio clip is uploaded in the Studio client.
*
* @return the name of the tab for the metadata type.
*/
TabType
getTab(void) const throw ()
{
return tab;
}
};

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.1 $
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/MetadataType.cxx,v $
------------------------------------------------------------------------------*/
@ -65,6 +65,11 @@ static const std::string id3TagAttrName = "id3Tag";
*/
static const std::string localizationKeyAttrName = "localizationKey";
/**
* The name of the attribute of the tab name in the metadataType element
*/
static const std::string tabAttrName = "tab";
/* =============================================== local function prototypes */
@ -76,8 +81,9 @@ static const std::string localizationKeyAttrName = "localizationKey";
*----------------------------------------------------------------------------*/
MetadataType :: MetadataType(Ptr<MetadataTypeContainer>::Ref container)
throw ()
: container(container),
tab(noTab)
{
this->container = container;
}
@ -87,10 +93,12 @@ MetadataType :: MetadataType(Ptr<MetadataTypeContainer>::Ref container)
MetadataType :: MetadataType(Ptr<MetadataTypeContainer>::Ref container,
Glib::ustring dcName,
Glib::ustring id3Tag,
Glib::ustring localizationKey)
Glib::ustring localizationKey,
TabType tab)
throw ()
: container(container),
tab(tab)
{
this->container = container;
this->dcName.reset(new Glib::ustring(dcName));
this->id3Tag.reset(new Glib::ustring(id3Tag));
this->localizationKey.reset(new Glib::ustring(localizationKey));
@ -128,6 +136,19 @@ MetadataType :: configure(const xmlpp::Element & element)
+ localizationKeyAttrName);
}
localizationKey.reset(new Glib::ustring(attribute->get_value()));
// get the tab, optional
tab = noTab;
if ((attribute = element.get_attribute(tabAttrName))) {
Glib::ustring tabString = attribute->get_value();
if (tabString == "main") {
tab = mainTab;
} else if (tabString == "music") {
tab = musicTab;
} else if (tabString == "talk") {
tab = talkTab;
}
}
}

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/MetadataTypeContainerTest.cxx,v $
------------------------------------------------------------------------------*/
@ -203,6 +203,15 @@ MetadataTypeContainerTest :: firstTest(void)
gotException = true;
}
CPPUNIT_ASSERT(gotException);
// two simple positive checks on the tab attribute
CPPUNIT_ASSERT(container->existsByDcName("dc:title"));
metadataType = container->getByDcName("dc:title");
CPPUNIT_ASSERT(metadataType->getTab() == MetadataType::mainTab);
CPPUNIT_ASSERT(container->existsByDcName("ls:buycdurl"));
metadataType = container->getByDcName("ls:buycdurl");
CPPUNIT_ASSERT(metadataType->getTab() == MetadataType::noTab);
}