Erste Variane von DublinCore standard Element Set Version 1.1. Kompiliert noch nicht!

git-svn-id: https://svn.libreccm.org/ccm/trunk@2159 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2013-06-01 09:08:44 +00:00
parent ad8bb933ab
commit b5e742dca4
27 changed files with 1889 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<?xml version="1.0"?>
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
name="ccm-cms-assets-dublincore"
prettyName="Dublin Core Asset"
version="6.6.1"
release="1"
webapp="ROOT">
<ccm:dependencies>
<ccm:requires name="ccm-core" version="6.6.0" relation="ge"/>
<ccm:requires name="ccm-cms" version="6.6.0" relation="ge"/>
<ccm:requires name="ccm-navigation" version="6.6.0" relation="ge"/>
<ccm:requires name="ccm-ldn-terms" version="6.6.0" relation="ge"/>
</ccm:dependencies>
<ccm:contacts>
<ccm:contact uri="http://www.redhat.com/software/rhea" type="website"/>
<ccm:contact uri="mailto:rhea@redhat.com" type="support"/>
</ccm:contacts>
<ccm:description>
The Dublin Core asset for compliance with the Dublin Core Metadata
standard.
This module is a relocation of former ccm-ldn-dublin.
The Red Hat Web Application Framework is a platform for writing
database-backed web applications in Java.
</ccm:description>
</ccm:application>

View File

@ -0,0 +1,133 @@
//
// Copyright (C) 2004 Red Hat Inc. All Rights Reserved.
//
// The contents of this file are subject to the Open Software License v2.1
// (the "License"); you may not use this file except in compliance with the
// License. You may obtain a copy of the License at
// http://rhea.redhat.com/licenses/osl2.1.html.
//
// Software distributed under the License is distributed on an "AS
// IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
// implied. See the License for the specific language governing
// rights and limitations under the License.
//
model com.arsdigita.cms.contentassets;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentPage;
object type DublinCoreES extends ContentItem {
String dcContributor = ca_dublincore_dces.contributor VARCHAR(4000);
String dcCoverage = ca_dublincore_dces.coverage VARCHAR(300);
String dcCreator = ca_dublincore_dces.creator VARCHAR(300);
String dcDate = ca_dublincore_dces.date VARCHAR(100);
String dcDescription = ca_dublincore_dces.description VARCHAR(4000);
String dcIdentifier = ca_dublincore_dces.identifier VARCHAR(4000);
String dcLanguage = ca_dublincore_dces.language VARCHAR(3);
String dcPublisher = ca_dublincore_dces.publisher VARCHAR(4000);
String dcRelation = ca_dublincore_dces.relation VARCHAR(4000);
String dcRights = ca_dublincore_dces.rights VARCHAR(4000);
String dcSource = ca_dublincore_dces.source VARCHAR(4000);
String dcSubject = ldn_dublin_core_items.subject VARCHAR(4000);
String dcType = ca_dublincore_dces.type VARCHAR(4000);
reference key(ca_dublincore_dces.dces_id);
}
association {
composite ContentItem[1..1] dcesOwner = join ca_dublincore_dces.item_id
to cms_items.item_id;
component DublinCoreES[0..1] dublinCore = join cms_items.item_id
to ca_dublincore_dces.item_id;
}
// This query returns related items with an exact, or subcategory match.
query AllRelatedItems {
BigDecimal itemID;
String title;
String type;
String objectType;
do {
select distinct i.item_id,
p.title,
t.label,
o.object_type
from cms_items i,
acs_objects o,
cms_pages p,
content_types t,
cat_object_category_map ocm1,
cat_object_category_map ocm2,
cat_cat_subcat_trans_index ccs1,
cat_cat_subcat_trans_index ccs2,
cat_category_purpose_map m
where i.version = 'live'
and i.item_id <> :itemID
and p.item_id = i.item_id
and i.item_id = o.object_id
and t.type_id = i.type_id
and ocm1.object_id = i.item_id
and ocm1.category_id = ccs2.subcategory_id
and ocm2.object_id = :itemID
and ocm2.category_id = ccs1.subcategory_id
and m.purpose_id = :purposeID
and ccs1.category_id = m.category_id
and ccs2.category_id = ocm2.category_id
} map {
itemID = i.item_id;
title = p.title;
type = t.label;
objectType = o.object_type;
}
}
// The above query is not entirely clear since I've
// removed the nested queries in favour of joins
//
// The basic plan is:
// Get all live content items
// with a 'Subject' category matching
// a subject category assigned to item foo
//
// The complication is that it needs to treat
// subject categories heirarchically.
// To do this we pull out all 'subject' categories,
// then restrict it by those that are assigned to the
// current item.
// This query should be equivalent to the one above
// select i.item_id,
// p.title,
// t.label
// from cms_items i,
// cms_pages p,
// content_types t,
// cat_object_category_map ocm1
// where i.version = 'live'
// and i.item_id <> 734036
// and p.item_id = i.item_id
// and t.type_id = i.type_id
// and ocm1.object_id = i.item_id
// and ocm1.category_id in (
// -- Get all categories with the specified
// -- category purpose
// select ccs1.subcategory_id
// from cat_cat_subcat_trans_index ccs1,
// cat_category_purpose_map m
// where m.purpose_id = 9909
// and ccs1.category_id = m.category_id
// and ccs.subcategory_id in (
// -- Get all categories & children for item
// select ccs2.subcategory_id
// from cat_object_category_map ocm2,
// cat_cat_subcat_trans_index ccs2
// where ocm2.object_id = 734036
// and ocm2.category_id = ccs2.category_id
// )
// );
//

View File

@ -0,0 +1,78 @@
//
// Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
model com.arsdigita.london.dublin;
// Pull out all items which have:
// * Matching LGCL category ID
// * Not in a subcat of the current Nav cat
// * Matching first Dublin keywords
query getRelatedItems {
BigDecimal[1..1] itemID;
BigDecimal[1..1] workingID;
String[1..1] title;
String[1..1] type;
String[1..1] objectType;
do {
select ci.item_id,
ci.master_id,
cp.title,
ct.label,
ao.object_type
from
(
select distinct bdm.object_id as unique_bundle_id
from
cat_object_category_map bsm,
cat_object_category_map bdm,
trm_terms tsd,
cms_bundles cb
where bsm.object_id = :bundleID
and bsm.category_id = bdm.category_id
and bdm.category_id = tsd.model_category_id
and tsd.domain = :subjectDomain
and cb.bundle_id = bdm.object_id
and bdm.object_id not in (
select bnm.object_id
from cat_object_category_map bnm,
cat_cat_subcat_trans_index sti
where bnm.category_id = sti.subcategory_id
and sti.category_id = :navCategoryID
)) unique_bundles,
cms_items ci,
cms_pages cp,
acs_objects ao,
content_types ct,
ldn_dublin_core_items dci
where ci.parent_id = unique_bundles.unique_bundle_id
and ci.item_id = cp.item_id
and ci.item_id = ao.object_id
and ci.item_id != :itemID
and ci.type_id = ct.type_id
and ci.item_id = dci.item_id
and dci.keywords like :keyword || '%'
and ci.version = 'live'
} map {
itemID = ci.item_id;
workingID = ci.master_id;
title = cp.title;
type = ct.label;
objectType = ao.object_type;
}
}

View File

@ -0,0 +1,2 @@
@@ ddl/oracle-se/create.sql
@@ ddl/oracle-se/deferred.sql

View File

@ -0,0 +1,4 @@
begin;
\i ddl/postgres/create.sql
\i ddl/postgres/deferred.sql
end;

View File

@ -0,0 +1 @@
alter table ldn_dublin_core_items add ccn_portal_instance varchar2(200);

View File

@ -0,0 +1,7 @@
alter table ldn_dublin_core_items add
(item_id integer constraint ldn_dub_cor_ite_ite_id_f_f7q6_ references cms_items(item_id));
update ldn_dublin_core_items dc
set item_id
= (select dcm.item_id from LDN_DUBLIN_CORE_ITEM_MAP dcm where dcm.dublin_id=dc.dublin_id);
drop table ldn_dublin_core_item_map;

View File

@ -0,0 +1,5 @@
begin;
alter table ldn_dublin_core_items add ccn_portal_instance varchar(200);
commit;

View File

@ -0,0 +1,12 @@
begin;
alter table ldn_dublin_core_items add
item_id integer constraint ldn_dub_cor_ite_ite_id_f_f7q6_ references cms_items(item_id);
update ldn_dublin_core_items
set item_id = dcm.item_id
from LDN_DUBLIN_CORE_ITEM_MAP dcm
where dcm.dublin_id=ldn_dublin_core_items.dublin_id;
drop table ldn_dublin_core_item_map;
commit;

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<xrd:adapters xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
<!-- First off the adapters for ContentItemPanel -->
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator">
<!-- Individual article sections -->
<xrd:adapter objectType="com.arsdigita.london.cms.dublin.DublinCoreItem">
<xrd:attributes rule="exclude">
<xrd:property name="/object/id"/>
<xrd:property name="/object/defaultDomainClass"/>
<xrd:property name="/object/objectType"/>
<xrd:property name="/object/displayName"/>
<xrd:property name="/object/isDeleted"/>
<xrd:property name="/object/ancestors"/>
<xrd:property name="/object/version"/>
</xrd:attributes>
</xrd:adapter>
</xrd:context>
<xrd:context name="com.arsdigita.cms.search.ContentPageMetadataProvider">
<!-- Individual article sections -->
<xrd:adapter objectType="com.arsdigita.london.cms.dublin.DublinCoreItem">
<xrd:attributes rule="exclude">
<xrd:property name="/object/id"/>
<xrd:property name="/object/defaultDomainClass"/>
<xrd:property name="/object/objectType"/>
<xrd:property name="/object/displayName"/>
<xrd:property name="/object/isDeleted"/>
<xrd:property name="/object/ancestors"/>
<xrd:property name="/object/version"/>
</xrd:attributes>
</xrd:adapter>
</xrd:context>
</xrd:adapters>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<registry>
<config class="com.arsdigita.cms.contentassets.DublinCoreConfig"
storage="ccm-cms-assets-dublincore/dublincore.properties"/>
</registry>

View File

@ -0,0 +1,18 @@
<load>
<requires>
<table name="inits"/>
<table name="acs_objects"/>
<initializer class="com.arsdigita.core.Initializer"/>
<table name="cms_items"/>
<initializer class="com.arsdigita.cms.Initializer"/>
</requires>
<provides>
<!--
<table name=""/>
-->
<initializer class="com.arsdigita.cms.contentassets.DublinCoreInitializer"/>
</provides>
<scripts>
<schema directory="ccm-cms-assets-dublincore"/>
</scripts>
</load>

View File

@ -0,0 +1,11 @@
<upgrade>
<version from="1.4.2" to="1.4.3">
<script sql="ccm-cms-assets-dublincore/upgrade/::database::-1.4.2-1.4.3.sql"/>
</version>
<version from="6.3.0" to="6.3.1">
<script sql="ccm-cms-assets-dublincore/upgrade/::database::-6.3.0-6.3.1.sql"/>
</version>
<version from="6.6.0" to="6.6.1">
<script sql="ccm-cms-assets-dublincore/upgrade/::database::-6.6.0-6.6.1.sql"/>
</version>
</upgrade>

View File

@ -0,0 +1,168 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.arsdigita.cms.contentassets;
import com.arsdigita.runtime.AbstractConfig;
import com.arsdigita.util.parameter.Parameter;
import com.arsdigita.util.parameter.StringParameter;
import com.arsdigita.util.parameter.BooleanParameter;
import org.apache.log4j.Logger;
/**
* Configuration object for the DublinCore asset.
*/
public class DublinCoreConfig extends AbstractConfig {
/** A logger instance to assist debugging. */
private static final Logger s_log = Logger.getLogger(DublinCoreConfig.class);
/** Singelton config object. */
private static DublinCoreConfig s_conf;
/**
* Gain a DublinCoreConfig object.
*
* Singelton pattern, don't instantiate a config object using the
* constructor directly!
* @return
*/
public static synchronized DublinCoreConfig instanceOf() {
if (s_conf == null) {
s_conf = new DublinCoreConfig();
s_conf.load();
}
return s_conf;
}
// ///////////////////////////////////////////////////////////////////////
//
// set of configuration parameters
/** Default Audience Domain Key preset in the authoring step ui */
private Parameter m_audience = new StringParameter(
"com.arsdigita.cms.contentassets.dublincore.audience_domain",
Parameter.OPTIONAL,
null);
/** Default Coverage Domain Key preset in the authoring step ui */
private Parameter m_coverageSpatial = new StringParameter(
"com.arsdigita.cms.contentassets.dublincore.coverage_spatial_domain",
Parameter.OPTIONAL,
null);
/** Default Units Domain Key preset in the authoring step ui */
private Parameter m_coverageUnit = new StringParameter(
"com.arsdigita.cms.contentassets.dublincore.coverage_units_domain",
Parameter.OPTIONAL,
null);
/** Default Default Owner preset in the authoring step ui */
private Parameter m_owner = new StringParameter(
"com.arsdigita.cms.contentassets.dublincore.owner_default",
Parameter.OPTIONAL,
null);
/** Default Default Owner Contact preset in the authoring step ui */
private Parameter m_owner_contact = new StringParameter(
"com.arsdigita.cms.contentassets.dublincore.owner_contact_default",
Parameter.OPTIONAL,
null);
/** Default Rights string preset in the authoring step ui */
private Parameter m_rights = new StringParameter(
"com.arsdigita.cms.contentassets.dublincore.rights_default",
Parameter.OPTIONAL,
null);
/** Default Publisher string preset in the authoring step ui */
private Parameter m_publisher = new StringParameter(
"com.arsdigita.cms.contentassets.dublincore.publisher_default",
Parameter.OPTIONAL,
null);
/** Default value wether to metadata should include CCN.PortalInclude */
private Parameter m_use_ccn_portal = new BooleanParameter(
"com.arsdigita.cms.contentassets.dublincore.use_ccn_portal_default",
Parameter.OPTIONAL,
Boolean.FALSE);
/** Default Related Items subject domain preset in the authoring step ui */
private Parameter m_relatedItemsSubjectDomain = new StringParameter(
"com.arsdigita.cms.contentassets.dublincore.related_items_subject_domain",
Parameter.OPTIONAL,
null);
/**
* Constructor just registers and loads the parameter.
*/
public DublinCoreConfig() {
register(m_audience);
register(m_coverageSpatial);
register(m_coverageUnit);
register(m_owner);
register(m_owner_contact);
register(m_rights);
register(m_publisher);
register(m_use_ccn_portal);
register(m_relatedItemsSubjectDomain);
loadInfo();
}
/**
*
* @return
*/
public String getAudienceDomain() {
return (String)get(m_audience);
}
public String getCoverageSpatialDomain() {
return (String)get(m_coverageSpatial);
}
public String getCoverageUnitDomain() {
return (String)get(m_coverageUnit);
}
public String getOwnerDefault() {
return (String)get(m_owner);
}
public String getRightsDefault() {
return (String)get(m_rights);
}
public String getPublisherDefault() {
return (String)get(m_publisher);
}
public boolean getUseCCNPortalMetadata() {
return ((Boolean)get(m_use_ccn_portal)).booleanValue();
}
public String getRelatedItemsSubjectDomain() {
return (String)get(m_relatedItemsSubjectDomain);
}
public String getOwnerContactDefault() {
return (String)get(m_owner_contact);
}
// Only for test suites
void setRelatedItemsSubjectDomain(String domain) {
set(m_relatedItemsSubjectDomain, domain);
}
}

View File

@ -0,0 +1,44 @@
com.arsdigita.cms.contentassets.dublincore.audience_domain.title=Audience Domain Key
com.arsdigita.cms.contentassets.dublincore.audience_domain.purpose=Audience Domain Key
com.arsdigita.cms.contentassets.dublincore.audience_domain.example=lgaudience
com.arsdigita.cms.contentassets.dublincore.audience_domain.format=[string]
com.arsdigita.cms.contentassets.dublincore.coverage_spatial_domain.title=Coverage Domain Key
com.arsdigita.cms.contentassets.dublincore.coverage_spatial_domain.purpose=Coverage Domain Key
com.arsdigita.cms.contentassets.dublincore.coverage_spatial_domain.example=lgcoverage
com.arsdigita.cms.contentassets.dublincore.coverage_spatial_domain.format=[string]
com.arsdigita.cms.contentassets.dublincore.coverage_units_domain.title=Units Domain Key
com.arsdigita.cms.contentassets.dublincore.coverage_units_domain.purpose=Units Domain Key
com.arsdigita.cms.contentassets.dublincore.coverage_units_domain.example=lgunits
com.arsdigita.cms.contentassets.dublincore.coverage_units_domain.format=[string]
com.arsdigita.cms.contentassets.dublincore.owner_default.title=Default Owner
com.arsdigita.cms.contentassets.dublincore.owner_default.purpose=Default Owner
com.arsdigita.cms.contentassets.dublincore.owner_default.example=Example Corp
com.arsdigita.cms.contentassets.dublincore.owner_default.format=[string]
com.arsdigita.cms.contentassets.dublincore.owner_contact_default.title=Default Owner Contact
com.arsdigita.cms.contentassets.dublincore.owner_contact_default.purpose=Default Owner Contact
com.arsdigita.cms.contentassets.dublincore.owner_contact_default.example=Example Corp
com.arsdigita.cms.contentassets.dublincore.owner_contact_default.format=[string]
com.arsdigita.cms.contentassets.dublincore.rights_default.title=Default Rights
com.arsdigita.cms.contentassets.dublincore.rights_default.purpose=Default Rights
com.arsdigita.cms.contentassets.dublincore.rights_default.example=Example Corp
com.arsdigita.cms.contentassets.dublincore.rights_default.format=[string]
com.arsdigita.cms.contentassets.dublincore.publisher_default.title=Defualt Publisher
com.arsdigita.cms.contentassets.dublincore.publisher_default.purpose=Default Publisher
com.arsdigita.cms.contentassets.dublincore.publisher_default.example=Example Corp
com.arsdigita.cms.contentassets.dublincore.publisher_default.format=[string]
com.arsdigita.cms.contentassets.dublincore.use_ccn_portal_default.title=Use CCN.PortalInclude
com.arsdigita.cms.contentassets.dublincore.use_ccn_portal_default.purpose=Whether the content metadata should include CCN.PortalInclude
com.arsdigita.cms.contentassets.dublincore.use_ccn_portal_default.example=false
com.arsdigita.cms.contentassets.dublincore.use_ccn_portal_default.format=[boolean]
com.arsdigita.cms.contentassets.dublincore.related_items_subject_domain.title=Related items subject domain
com.arsdigita.cms.contentassets.dublincore.related_items_subject_domain.purpose=Related items subject domain
com.arsdigita.cms.contentassets.dublincore.related_items_subject_domain.example=LGCL
com.arsdigita.cms.contentassets.dublincore.related_items_subject_domain.format=[string]

View File

@ -0,0 +1,92 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.arsdigita.cms.contentassets;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.contentassets.ui.DublinCoreEdit;
import com.arsdigita.cms.contentassets.util.DublinCoreGlobalizationUtil;
import com.arsdigita.cms.contenttypes.ContentAssetInitializer;
import com.arsdigita.globalization.GlobalizedMessage;
/**
* Initializes the dublin core content asset.
*
* The class just implements all abstract methods of the super class
*/
public class DublinCoreInitializer extends ContentAssetInitializer {
/**
* Constructor, sets its specific manifest file and delegates to super class.
*/
public DublinCoreInitializer() {
super("ccm-cms-assets-dublincore.pdl.mf");
}
/**
* The base type against which the asset is defined,
* typically com.arsdigita.cms.ContentPage
*/
public String getBaseType() {
return ContentPage.BASE_DATA_OBJECT_TYPE;
}
/**
* Returns the path to the XML file defintions for the asset, eg:
* /WEB-INF/traversal-adapters/com/arsdigita/cms/contentassets/DublinCore.xml
*/
public String getTraversalXML() {
return TRAVERSAL_ADAPTER_BASE_DIR + "DublinCore.xml";
}
/**
* The name of the association between the item
* and the asset, eg 'fileAttachments'.
*/
public String getProperty() {
return "dublinCore";
}
/**
* The class of the authoring kit step
*/
public Class getAuthoringStep() {
return DublinCoreEdit.class;
}
/**
* The label for the authoring step
*/
public GlobalizedMessage getAuthoringStepLabel() {
return DublinCoreGlobalizationUtil.AuthoringStepLabel();
}
/**
* The description for the authoring step
*/
public GlobalizedMessage getAuthoringStepDescription() {
return DublinCoreGlobalizationUtil.AuthoringStepDescription();
}
/**
* The sort key for the authoring step
*/
public int getAuthoringStepSortKey() {
return 3; // XXX config param please
}
}

View File

@ -0,0 +1,2 @@
com.arsdigita.cms.contentassets.dublin_core_label=Metadata
com.arsdigita.cms.contentassets.dublin_core_description=Enter the Dublin Core metadata

View File

@ -0,0 +1,68 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.arsdigita.cms.contentassets;
import com.arsdigita.navigation.RelatedItemsQuery;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.categorization.Category;
/**
*
*
*/
class RelatedItemsQueryImpl extends RelatedItemsQuery {
/** PDL connector */
public static final String QUERY_NAME
= "com.arsdigita.cms.contentassets.getRelatedItems";
public static final String ITEM_ID = "itemID";
public static final String BUNDLE_ID = "bundleID";
public static final String KEYWORD = "keyword";
public static final String NAV_CATEGORY_ID = "navCategoryID";
public static final String SUBJECT_DOMAIN = "subjectDomain";
/**
*
* @param bundle
* @param page
* @param keyword
* @param current
*/
RelatedItemsQueryImpl(ContentBundle bundle,
ContentPage page,
String keyword,
Category current) {
super(QUERY_NAME);
setParameter(ITEM_ID, page.getID());
setParameter(BUNDLE_ID, bundle.getID());
setParameter(KEYWORD, keyword);
setParameter(SUBJECT_DOMAIN,
DublinCoreES.getConfig()
.getRelatedItemsSubjectDomain());
setParameter(NAV_CATEGORY_ID,
current.getID());
}
}

View File

@ -0,0 +1,44 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>com.arsdigita.cms.contentassets.DublinCore</title>
</head>
<body>
<p>
The DublinCore asset provides meta data functionality according the the
Dublin Dore Metadata Initiative (DCMI).
</p>
<p>
For a details information see the Dublin Core
<a href="http://wiki.dublincore.org/index.php/User_Guide">User Guide</a>
</p>
<p>
"Dublin Core" is a set of 15 generic elements for describing resources:
Creator, Contributor, Publisher, Title, Date, Language, Format, Subject,
Description, Identifier, Relation, Source, Type, Coverage, and Rights.
These are name the "Dublin Core Metadata Elemenmt Set (DCES) created in
1995, currently at version 1.1 (2012)
</p>
<p>
According to the Dublin Core initiative it is about more than those 15
elements. It is part of the "Semantic Weg" approach. The initative
developed "DCMI Metadata Terms", which is a larger set that includes the
15 elements along with several dozen related properties and classes. They
constitute an "application profile" which uses DCMI metadata terms together
with terms from other, more specialized vocabularies to describe a specific
type of information
</p>
<p>
The CCM DublinCore asset is an implementation of the Dublin Core Metadata
Element Set, version 1.1 (revision 2012). For detailed information see the
<a href="http://dublincore.org/documents/dces/">element set reference guide</a>.
It is meant to be expandable to serve as a base for a domain or user specific
and more complex set of metadata or an application profile.
</p>
<p>
<i>DublinCoreItem.java</i> is the main domain class.
</p>
</body>
</html>

View File

@ -0,0 +1,60 @@
/*
* Copyright (C) 2004 Red Hat Inc. All Rights Reserved.
*
* The contents of this file are subject to the Open Software License v2.1
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://rhea.redhat.com/licenses/osl2.1.html.
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
*/
package com.arsdigita.cms.contentassets.ui;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
/**
* Dublin Core authoring kit editing step.
*
* Main entry point into authoring functionality as defined in
* DublinCoreInitializer. It just overwrites the constructor to create a page
* to display the current values and a page to edit the modifiable properties.
*
*
* must call setDisplayComponent();
* must call addComponent() 0 or more times;
*
* @author slater@arsdigita.com
*/
public class DublinCoreEdit extends SimpleEditStep {
/**
* Constructor, invokes super class and creates two page elements to display
* all properties and another one to edit the modifiable ones.
*
* @param itemModel
* @param parent
*/
public DublinCoreEdit(ItemSelectionModel itemModel,
AuthoringKitWizard parent) {
super(itemModel, parent);
DublinCoreForm edit = new DublinCoreForm(itemModel);
DublinCoreSummary display = new DublinCoreSummary(itemModel);
setDisplayComponent(display);
add("edit",
"edit",
new WorkflowLockedComponentAccess(edit, itemModel),
edit.getCancelButton()
);
}
}

View File

@ -0,0 +1,68 @@
/*
* Copyright (C) 2004 Red Hat Inc. All Rights Reserved.
*
* The contents of this file are subject to the Open Software License v2.1
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://rhea.redhat.com/licenses/osl2.1.html.
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
*/
package com.arsdigita.cms.contentassets.ui;
import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.form.Submit;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ItemSelectionModel;
import org.apache.log4j.Logger;
/**
*
*
*/
public class DublinCoreForm extends Form {
/** A logger instance to assist debugging. */
private static final Logger s_log =
Logger.getLogger(DublinCoreFormSection.class);
private ItemSelectionModel m_itemModel;
private DublinCoreFormSection m_section;
/**
* Constructor
* @param itemModel
*/
public DublinCoreForm(ItemSelectionModel itemModel) {
super("dublin");
m_itemModel = itemModel;
m_section = new DublinCoreFormSection(false) {
@Override
protected String getInitialDescription(ContentItem item) {
return ((ContentPage) item).getSearchSummary();
}
protected ContentItem getSelectedItem(PageState state) {
return m_itemModel.getSelectedItem(state);
}
};
add(m_section, ColumnPanel.FULL_WIDTH);
}
public Submit getCancelButton() {
return m_section.getCancelButton();
}
}

View File

@ -0,0 +1,342 @@
/*
* Copyright (C) 2004 Red Hat Inc. All Rights Reserved.
*
* The contents of this file are subject to the Open Software License v2.1
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://rhea.redhat.com/licenses/osl2.1.html.
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
*/
package com.arsdigita.cms.contentassets.ui;
import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.FormSection;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SaveCancelSection;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.DateTime;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.Submit;
import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.form.Widget;
import com.arsdigita.bebop.parameters.DateTimeParameter;
import com.arsdigita.bebop.parameters.StringLengthValidationListener;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.parameters.TrimmedStringParameter;
import com.arsdigita.cms.contentassets.DublinCoreES;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.Party;
import com.arsdigita.london.terms.Domain;
import java.util.Date;
import org.apache.log4j.Logger;
/**
*
*
*/
public abstract class DublinCoreFormSection extends FormSection
implements FormInitListener,
FormProcessListener {
/** A logger instance to assist debugging. */
private static final Logger s_log =
Logger.getLogger(DublinCoreFormSection.class);
// private TextField m_contributor; //nevertheless, contrib is a db field
// Originally coverage(Spatial) is a controlled list, therefore Widget here
private Widget m_coverage;
private TextArea m_creator; //default value pulled in frim config, edited
// value persisted in database
private TextField m_dateValid;
private TextArea m_description;
// private TextField m_format;
// private TextField m_identifier;
// private TextField m_language;
private TextArea m_publisher;
/* Relation: Related resource. Recommended to identify by a string
* conforming to a formal identification system. */
// private TextField m_relation;
/** Rights: Information about rights held in and over the resource.
* Statement about various property rights. */
private TextArea m_rights;
/* Related resource from which the resource is derived. Recommended to
* identify by a string conforming to a formal identification system. */
// private TextField m_source;
/** Topic of the resource, typically represented by keywords or
* classiofication codes. */
// private TextField m_subject;
private TextField m_keywords;
/* Given name, not persisted, retrieved from associated content item. */
// private TextField m_title;
/* * Nature or genre, recommended to use a controlled vocabulary */
// private TextField m_type;
/** Flag whether the discription item should be editable after retrieving
* its value from the associated content item description (abstract) */
private boolean editableDescription;
private Submit m_cancel;
/**
* Constructor creates the form elements.
*
* @param editableDescription whether the discription item should be editable
*/
public DublinCoreFormSection(boolean editableDescription) {
this.editableDescription = editableDescription;
m_dateValid = new TextField(new StringParameter("dateValid"));
m_dateValid.addValidationListener(new StringLengthValidationListener(
100));
m_creator = new TextArea(new StringParameter("creatorOwner"));
m_creator.addValidationListener(new
StringLengthValidationListener(300));
m_creator.setCols(50);
m_creator.setRows(3);
m_description = new TextArea(new StringParameter("description"));
if (editableDescription) {
m_description.addValidationListener(
new StringLengthValidationListener(4000));
m_description.setCols(50);
m_description.setRows(10);
} else {
m_description.setReadOnly();
}
m_publisher = new TextArea(new StringParameter("publisher"));
m_publisher.addValidationListener(new
StringLengthValidationListener(4000));
m_publisher.setCols(50);
m_publisher.setRows(5);
m_rights = new TextArea(new StringParameter("rights"));
m_rights.addValidationListener(new StringLengthValidationListener(4000));
m_rights.setCols(50);
m_rights.setRows(10);
m_keywords = new TextField(new TrimmedStringParameter("keywords"));
m_keywords.addValidationListener(new StringLengthValidationListener(
4000));
m_keywords.addValidationListener(new DublinCoreKeywordsValidationListener());
m_keywords.setHint("Enter a list of keywords, separated with commas");
m_keywords.setSize(50);
add(new Label("Coverage:", Label.BOLD), ColumnPanel.RIGHT);
add(m_coverage);
add(new Label("Date (valid):", Label.BOLD), ColumnPanel.RIGHT);
add(m_dateValid);
add(new Label("Creator (owner):", Label.BOLD), ColumnPanel.RIGHT);
add(m_creator);
add(new Label("Description:", Label.BOLD), ColumnPanel.RIGHT);
add(m_description);
add(new Label("Publisher:", Label.BOLD), ColumnPanel.RIGHT);
add(m_publisher);
add(new Label("Rights:", Label.BOLD), ColumnPanel.RIGHT);
add(m_rights);
add(new Label("Keywords:", Label.BOLD), ColumnPanel.RIGHT);
add(m_keywords);
SaveCancelSection saveCancel = new SaveCancelSection();
m_cancel = saveCancel.getCancelButton();
add(saveCancel, ColumnPanel.FULL_WIDTH);
addInitListener(this);
addProcessListener(this);
}
/**
*
* @return
*/
public Submit getCancelButton() {
return m_cancel;
}
/**
*
* @param name
* @param key
* @return
*/
protected Widget createControlledList(String name, String key) {
if (s_log.isDebugEnabled()) {
s_log.debug("Creating controlled list with " + name + " key "
+ key);
}
Domain domain = null;
if (key != null) {
try {
domain = Domain.retrieve(key);
} catch (DataObjectNotFoundException ex) {
s_log.warn("Cannot find controlled list key " + key
+ " for field " + name);
// nada
}
}
if (domain == null) {
TextField widget = new TextField(name);
widget.setSize(40);
return widget;
} else {
DublinCoreControlledList widget = new DublinCoreControlledList(name, domain);
return widget;
}
}
/**
*
* @param fse
* @throws FormProcessException
*/
public void init(FormSectionEvent fse) throws FormProcessException {
PageState state = fse.getPageState();
ContentItem item = getSelectedItem(state);
if (item == null) {
return;
}
DublinCoreES dcItem = DublinCoreES.findByOwner(item);
if (dcItem == null) {
m_creator.setValue(state, DublinCoreES.getConfig()
.getOwnerDefault());
m_publisher.setValue(state, DublinCoreES.getConfig()
.getPublisherDefault());
m_rights.setValue(state, DublinCoreES.getConfig()
.getRightsDefault());
m_description.setValue(state, getInitialDescription(item));
return;
}
m_coverage.setValue(state, dcItem.getCoverage());
m_creator.setValue(state,
dcItem.getCreator() == null ?
DublinCoreES.getConfig().getOwnerDefault() :
dcItem.getCreator()
);
m_publisher.setValue(state,
dcItem.getPublisher() == null ? DublinCoreES.getConfig()
.getPublisherDefault() : dcItem.getPublisher());
m_rights.setValue(state, dcItem.getRights() == null ? DublinCoreES
.getConfig().getRightsDefault() : dcItem.getRights());
// m_keywords.setValue(state, dcItem.getKeywords());
if (editableDescription) {
m_description.setValue(state, dcItem.getDescription());
} else {
m_description.setValue(state, getInitialDescription(item));
}
// if (DublinCoreES.getConfig().getUseCCNPortalMetadata()) {
// m_ccn_portal_instance
// .setValue(state, dcItem.getCcnPortalInstance());
// }
}
/**
*
* @param fse
* @throws FormProcessException
*/
public void process(FormSectionEvent fse) throws FormProcessException {
PageState state = fse.getPageState();
ContentItem item = getSelectedItem(state);
if (item == null) {
return;
}
DublinCoreES dcItem = DublinCoreES.findByOwner(item);
if (dcItem == null) {
dcItem = DublinCoreES.create(item);
}
dcItem.setCoverage((String) m_coverage.getValue(state));
dcItem.setDate((String) m_dateValid.getValue(state));
dcItem.setCreator((String) m_creator.getValue(state));
dcItem.setPublisher((String) m_publisher.getValue(state));
dcItem.setRights((String) m_rights.getValue(state));
// dcItem.setKeywords((String) m_keywords.getValue(state));
if (editableDescription) {
saveDescription((String) m_description.getValue(state), item, dcItem);
}
dcItem.save();
}
/**
*
* @param state
* @return
*/
protected abstract ContentItem getSelectedItem(PageState state);
/**
*
* @param item
* @return
*/
protected String getInitialDescription(ContentItem item) {
return "";
}
/**
*
* @param description
* @param item
* @param dcItem
*/
protected void saveDescription(String description, ContentItem item, DublinCoreES dcItem ) {
dcItem.setDescription(description);
}
}

View File

@ -0,0 +1,301 @@
/*
* Copyright (C) 2004 Red Hat Inc. All Rights Reserved.
*
* The contents of this file are subject to the Open Software License v2.1
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://rhea.redhat.com/licenses/osl2.1.html.
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
*/
package com.arsdigita.cms.contentassets.ui;
import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.List;
import com.arsdigita.bebop.list.ListCellRenderer;
import com.arsdigita.bebop.list.ListModel;
import com.arsdigita.bebop.list.ListModelBuilder;
import com.arsdigita.cms.contentassets.DublinCoreES;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.category.CategoryIteratorListModel;
import com.arsdigita.util.LockableImpl;
import com.arsdigita.xml.Element;
import java.util.Date;
import java.text.DateFormat;
import org.apache.log4j.Category;
/**
*
*
*/
public class DublinCoreSummary extends ColumnPanel {
private static final Category s_log =
Category.getInstance( DublinCoreSummary.class );
private Label m_title;
private Label m_contributor;
private Label m_coverage;
private Label m_creator;
private Label m_date_created;
private Label m_date_issued;
private Label m_date_modified;
private Label m_dateValid;
private Label m_description;
private Label m_identifier;
private Label m_language;
private Label m_publisher;
private Label m_relation;
private Label m_rights;
private Label m_source;
private Label m_subject;
private Label m_documentType;
private List m_categories;
private ItemSelectionModel m_itemModel;
/**
* Constructor, creates the panel.
*
* @param itemModel
*/
public DublinCoreSummary(ItemSelectionModel itemModel) {
super(2);
setColumnWidth( 1, "40%" );
m_itemModel = itemModel;
m_title = new Label();
m_date_created = new Label();
m_date_issued = new Label();
m_date_modified = new Label();
m_dateValid = new Label();
m_documentType = new Label();
m_creator = new Label();
m_description = new Label();
m_publisher = new Label();
m_rights = new Label();
m_language = new Label();
m_subject = new Label();
ListCellRenderer simpleCellRenderer = new SimpleCellRenderer();
m_categories = new List(new CategoryListModelBuilder(itemModel,
"subject"));
m_categories.setCellRenderer(simpleCellRenderer);
add(new Label("Title:", Label.BOLD), ColumnPanel.RIGHT);
add(m_title);
add(new Label("Coverage:", Label.BOLD),
ColumnPanel.RIGHT);
add(m_coverage);
add(new Label("Creator (owner):", Label.BOLD),
ColumnPanel.RIGHT);
add(m_creator);
add(new Label("Date (created):", Label.BOLD),
ColumnPanel.RIGHT);
add(m_date_created);
add(new Label("Date (issued):", Label.BOLD),
ColumnPanel.RIGHT);
add(m_date_issued);
add(new Label("Date (modified):", Label.BOLD),
ColumnPanel.RIGHT);
add(m_date_modified);
add(new Label("Date (valid):", Label.BOLD),
ColumnPanel.RIGHT);
add(m_dateValid);
add(new Label("Description:", Label.BOLD),
ColumnPanel.RIGHT);
add(m_description);
add(new Label("Publisher:", Label.BOLD),
ColumnPanel.RIGHT);
add(m_publisher);
add(new Label("Rights:", Label.BOLD),
ColumnPanel.RIGHT);
add(m_rights);
add(new Label("Type (document type):", Label.BOLD),
ColumnPanel.RIGHT);
add(m_documentType);
// add(new Label("Disposal (review):", Label.BOLD),
// ColumnPanel.RIGHT);
// add(m_disposalReview);
add(new Label("Language:", Label.BOLD),
ColumnPanel.RIGHT);
add(m_language);
add(new Label("Keywords:", Label.BOLD),
ColumnPanel.RIGHT);
add(m_subject);
add(new Label("Subject Categories:", Label.BOLD),
ColumnPanel.RIGHT | ColumnPanel.TOP);
add(m_categories);
}
/**
*
* @param state
* @param parent
*/
@Override
public void generateXML(PageState state,
Element parent) {
ContentPage item = (ContentPage)m_itemModel.getSelectedObject(state);
DublinCoreES dces = DublinCoreES.findByOwner(item);
/* Retrieve dc title from associated content items title. Not persisted
* in dces database table. */
m_title.setLabel(item.getDisplayName(), state);
if (dces != null) {
m_coverage.setLabel(dces.getCoverage(), state);
}
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
DateFormat.MEDIUM);
ContentPage latest;
String issueDate;
if (item.isLive()) {
latest = (ContentPage)item.getLiveVersion();
Date issued = item.getLifecycle().getStartDate();
if (issued != null) {
issueDate = dateFormat.format(issued);
} else {
issueDate = "";
}
} else {
latest = item;
issueDate = "";
}
String creationDate = (item.getCreationDate() != null ?
dateFormat.format( item.getCreationDate()) : "" );
String modifiedDate = (latest.getLastModifiedDate() != null ?
dateFormat.format( latest.getLastModifiedDate()) : "");
m_date_created.setLabel( creationDate, state );
m_date_issued.setLabel( issueDate, state );
m_date_modified.setLabel( modifiedDate, state );
if (dces != null) {
m_creator.setLabel(dces.getCreator(), state);
}
m_description.setLabel(item.getSearchSummary(), state);
if (dces != null) {
m_publisher.setLabel(dces.getPublisher(), state);
m_rights.setLabel(dces.getRights(), state);
}
m_documentType.setLabel(item.getContentType().getLabel(), state);
m_language.setLabel(item.getLanguage(), state);
if (dces != null) {
m_dateValid.setLabel(dces.getDate(), state);
// m_keywords.setLabel(dces.getKeywords(), state); will be Subject!
}
super.generateXML(state, parent);
}
/**
*
*/
protected class CategoryListModelBuilder extends LockableImpl
implements ListModelBuilder {
private ItemSelectionModel m_itemModel;
private String m_context;
/**
*
* @param itemModel
* @param context
*/
public CategoryListModelBuilder(ItemSelectionModel itemModel,
String context) {
m_itemModel = itemModel;
m_context = context;
}
/**
*
* @param l
* @param state
* @return
*/
public ListModel makeModel( List l, PageState state ) {
ContentPage item = (ContentPage) m_itemModel.getSelectedObject(state);
return new CategoryIteratorListModel(item.getCategories(m_context));
}
}
/**
*
*/
protected class SimpleCellRenderer implements ListCellRenderer {
/**
*
* @param list
* @param state
* @param value
* @param key
* @param index
* @param isSelected
* @return
*/
public Component getComponent(List list,
PageState state,
Object value,
String key,
int index,
boolean isSelected) {
return new Label(value.toString());
}
};
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.arsdigita.cms.contentassets;
import com.arsdigita.tools.junit.extensions.BaseTestSetup;
import com.arsdigita.tools.junit.extensions.CoreTestSetup;
import com.arsdigita.tools.junit.framework.PackageTestSuite;
import junit.framework.Test;
public class DublinSuite extends PackageTestSuite {
public DublinSuite() {
super();
}
public DublinSuite(Class theClass) {
super(theClass);
}
public DublinSuite(String name) {
super(name);
}
public static Test suite() {
DublinSuite suite = new DublinSuite();
populateSuite(suite);
BaseTestSetup wrapper = new DublinTestSetup(suite);
return wrapper;
}
public static void main(String[] args) throws Exception {
junit.textui.TestRunner.run( suite() );
}
}

View File

@ -0,0 +1,50 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.arsdigita.cms.contentassets;
import junit.framework.Test;
import junit.framework.TestSuite;
import com.arsdigita.tools.junit.extensions.CoreTestSetup;
/**
* DublinTestSetup
*
* Utility extension of BaseTestSetup that automatically adds the core initializer
*
*/
public class DublinTestSetup extends CoreTestSetup {
public DublinTestSetup(Test test, TestSuite suite) {
super(test, suite);
}
public DublinTestSetup(TestSuite suite) {
super(suite);
}
protected void setUp() throws Exception {
addRequiredInitializer("com.arsdigita.cms.Initializer");
addRequiredInitializer("com.arsdigita.london.util.Initializer");
addRequiredInitializer("com.arsdigita.london.atoz.Initializer");
addRequiredInitializer("com.arsdigita.london.terms.Initializer");
addRequiredInitializer("com.arsdigita.navigation.Initializer");
addRequiredInitializer("com.arsdigita.london.cms.dublin.Initializer");
super.setUp();
}
}

View File

@ -0,0 +1,243 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.arsdigita.cms.contentassets;
import com.arsdigita.london.util.junit.BaseTestCase;
import com.arsdigita.cms.Article;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ui.authoring.PageCreate;
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
import com.arsdigita.categorization.Category;
import com.arsdigita.categorization.CategoryCollection;
import com.arsdigita.london.terms.Term;
import com.arsdigita.london.terms.Domain;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.HashMap;
import java.util.Date;
import java.net.URL;
import java.net.MalformedURLException;
import java.math.BigDecimal;
import org.apache.log4j.Logger;
public class RelatedItemsTest extends BaseTestCase {
private final static Logger s_log = Logger.getLogger(RelatedItemsTest.class);
private static final int NITEMS = 9;
private ContentBundle[] m_bundles;
private ContentPage[] m_items;
private ContentPage[] m_live;
private Category m_mainNavCat;
public RelatedItemsTest( String name ) {
super( name );
}
public void setUp() {
m_items = new ContentPage[NITEMS];
m_live = new ContentPage[NITEMS];
m_bundles = new ContentBundle[NITEMS];
ContentSection section = createContentSection();
ContentType type = createContentType();
for (int i= 0 ; i < NITEMS ; i++) {
m_items[i] = createItem(type, i);
m_bundles[i] = createBundle(section, m_items[i]);
}
DublinCoreItem.getConfig().setRelatedItemsSubjectDomain("TEST-LGCL");
Domain lgcl = createDomain("TEST-LGCL");
Domain nav = createDomain("TEST-NAV");
Term mainNav = createTerm(nav, 1);
Term mainSubNav = createTerm(nav, 2);
Term otherNav = createTerm(nav, 3);
mainNav.addNarrowerTerm(mainSubNav, true, true);
Term mainLGCL = createTerm(lgcl, 1);
Term otherLGCL = createTerm(lgcl, 2);
// Main item
mainNav.addObject(m_bundles[0]);
CategoryCollection cats = m_bundles[0].getCategoryCollection();
assertTrue(cats.next());
m_mainNavCat = cats.getCategory();
assertTrue(!cats.next());
mainLGCL.addObject(m_bundles[0]);
createDublin(m_items[0], "foo");
// Negative: Item in same nav cat with matching lgcl & matching 1st keyword
mainNav.addObject(m_bundles[1]);
mainLGCL.addObject(m_bundles[1]);
createDublin(m_items[1], "foo");
// Negative: Item in sub nav cat with matching lgcl & matching 1st keyword
mainSubNav.addObject(m_bundles[2]);
mainLGCL.addObject(m_bundles[2]);
createDublin(m_items[2], "foo");
// Positive: Item in diff nav cat with matching lgcl & matching 1st keyword
otherNav.addObject(m_bundles[3]);
mainLGCL.addObject(m_bundles[3]);
createDublin(m_items[3], "foo");
// Positive: Item in diff nav cat with matching
// lgcl & matching 1st keyword, non-match second
otherNav.addObject(m_bundles[4]);
mainLGCL.addObject(m_bundles[4]);
createDublin(m_items[4], "foo,bar");
// Negative: Item in diff nav cat with matching
// lgcl & non-match 1st keyword, matching 2nd
otherNav.addObject(m_bundles[5]);
mainLGCL.addObject(m_bundles[5]);
createDublin(m_items[5], "bar,foo");
// Negative: Item in diff nav cat with non-matching
// lgcl & matching 1st keyword
otherNav.addObject(m_bundles[6]);
otherLGCL.addObject(m_bundles[6]);
createDublin(m_items[6], "foo");
// Negative: Item in diff nav cat with non-matching
// lgcl & matching 1st keyword, non-match second
otherNav.addObject(m_bundles[7]);
otherLGCL.addObject(m_bundles[7]);
createDublin(m_items[7], "foo,bar");
// Negative: Item in diff nav cat with non-matching
// lgcl & non-match 1st keyword, matching 2nd
otherNav.addObject(m_bundles[8]);
otherLGCL.addObject(m_bundles[8]);
createDublin(m_items[8], "bar,foo");
LifecycleDefinition def = createLifecycleDefintion();
for (int i = 0 ; i < m_items.length ; i++) {
m_live[i] = (ContentPage)m_items[i].publish(def, new Date());
m_live[i].getLifecycle().start();
}
}
private LifecycleDefinition createLifecycleDefintion() {
LifecycleDefinition def = new LifecycleDefinition();
def.setLabel("Test infinite");
def.addPhaseDefinition("Forever", "A long time", null, null, null);
return def;
}
private Domain createDomain(String name) {
try {
Domain domain = Domain.create(
name,
new URL("http://www.example.com/test/" + name),
name,
name,
"1.0",
new Date());
return domain;
} catch (MalformedURLException ex) {
throw new RuntimeException("Oh no you don't");
}
}
private Term createTerm(Domain domain,
int i) {
return Term.create(new Integer(i),
"term" + i,
false,
null,
domain);
}
public DublinCoreItem createDublin(ContentPage item,
String keywords) {
DublinCoreItem dc = DublinCoreItem.create(item);
dc.setKeywords(keywords);
return dc;
}
private ContentSection createContentSection() {
return ContentSection.create("test-section");
}
private ContentType createContentType() {
ContentType type = new ContentType();
type.setAssociatedObjectType(Article.BASE_DATA_OBJECT_TYPE);
type.setLabel("Test Article");
type.setClassName(PageCreate.class.getName());
return type;
}
private ContentPage createItem(ContentType type,
int i) {
ContentPage page = new Article();
page.setLanguage("en");
page.setName("item-" + i);
page.setTitle("Item " + i);
page.setContentType(type);
return page;
}
private ContentBundle createBundle(ContentSection section,
ContentPage page) {
ContentBundle bundle = new ContentBundle(page);
bundle.setParent(section.getRootFolder());
return bundle;
}
public void tearDown() {
}
public void testRelatedItems() {
RelatedItemsQueryFactoryImpl impl = new RelatedItemsQueryFactoryImpl();
RelatedItemsQueryImpl query = (RelatedItemsQueryImpl)
impl.getRelatedItems(m_items[0],
m_mainNavCat);
int i = 3;
while (query.next()) {
BigDecimal workingId = query.getWorkingID();
BigDecimal itemId = query.getItemID();
System.out.println("WO" + workingId + " " + itemId);
assertTrue(workingId.equals(m_items[i].getID()));
assertTrue(itemId.equals(m_live[i].getID()));
i++;
}
assertTrue(i == 5);
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cms="http://www.arsdigita.com/cms/1.0"
version="1.0">
<xsl:template name="DublinMetaDataHeader">
<xsl:for-each select="dublinCore/*">
<xsl:if test="starts-with(name(),'dc')">
<meta>
<xsl:attribute name="name"><xsl:text>DC.</xsl:text>
<xsl:value-of select="substring(name(),3)" />
</xsl:attribute>
<xsl:attribute name="content"><xsl:value-of select="." /></xsl:attribute>
</meta>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>