001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-impl/api-impl/src/java/org/sakaiproject/metaobj/shared/mgt/factories/DbXmlHomeFactoryImpl.java $
003: * $Id: DbXmlHomeFactoryImpl.java 20050 2007-01-02 19:37:37Z john.ellis@rsmart.com $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.metaobj.shared.mgt.factories;
021:
022: import java.util.Iterator;
023: import java.util.Map;
024:
025: import org.sakaiproject.metaobj.shared.mgt.HomeFactory;
026: import org.sakaiproject.metaobj.shared.mgt.ReadableObjectHome;
027: import org.sakaiproject.metaobj.shared.mgt.StructuredArtifactDefinitionManager;
028: import org.sakaiproject.metaobj.shared.mgt.home.StructuredArtifactDefinition;
029: import org.sakaiproject.metaobj.shared.model.Id;
030: import org.sakaiproject.metaobj.shared.model.StructuredArtifactDefinitionBean;
031:
032: /**
033: * Created by IntelliJ IDEA.
034: * User: John Ellis
035: * Date: Apr 9, 2004
036: * Time: 12:51:01 PM
037: * To change this template use File | Settings | File Templates.
038: */
039: public class DbXmlHomeFactoryImpl extends HomeFactoryBase implements
040: HomeFactory {
041:
042: private StructuredArtifactDefinitionManager structuredArtifactDefinitionManager;
043:
044: public boolean handlesType(String objectType) {
045: return (getHome(objectType) != null);
046: }
047:
048: public Map getHomes(Class requiredHomeType) {
049: return super .getHomes(requiredHomeType);
050: }
051:
052: public ReadableObjectHome findHomeByExternalId(String externalId,
053: Id worksiteId) {
054: return createHome(getStructuredArtifactDefinitionManager()
055: .loadHomeByExternalType(externalId, worksiteId));
056: }
057:
058: public ReadableObjectHome getHome(String objectType) {
059: return createHome(getStructuredArtifactDefinitionManager()
060: .loadHome(objectType));
061: }
062:
063: public Map getWorksiteHomes(Id worksiteId) {
064: return createHomes(getStructuredArtifactDefinitionManager()
065: .getWorksiteHomes(worksiteId));
066: }
067:
068: public Map getWorksiteHomes(Id worksiteId, boolean includeHidden) {
069: return createHomes(getStructuredArtifactDefinitionManager()
070: .getWorksiteHomes(worksiteId, true));
071: }
072:
073: public Map getHomes() {
074: return createHomes(getStructuredArtifactDefinitionManager()
075: .getHomes());
076: }
077:
078: protected Map createHomes(Map homeBeans) {
079: for (Iterator i = homeBeans.entrySet().iterator(); i.hasNext();) {
080: Map.Entry entry = (Map.Entry) i.next();
081: entry
082: .setValue(createHome((StructuredArtifactDefinitionBean) entry
083: .getValue()));
084: }
085: return homeBeans;
086: }
087:
088: protected ReadableObjectHome createHome(
089: StructuredArtifactDefinitionBean sadBean) {
090: return new StructuredArtifactDefinition(sadBean);
091: }
092:
093: public StructuredArtifactDefinitionManager getStructuredArtifactDefinitionManager() {
094: return structuredArtifactDefinitionManager;
095: }
096:
097: public void setStructuredArtifactDefinitionManager(
098: StructuredArtifactDefinitionManager structuredArtifactDefinitionManager) {
099: this.structuredArtifactDefinitionManager = structuredArtifactDefinitionManager;
100: }
101:
102: }
|