01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-impl/api-impl/src/java/org/sakaiproject/metaobj/shared/mgt/impl/StructuredArtifactFinder.java $
03: * $Id: StructuredArtifactFinder.java 22427 2007-03-12 15:41:41Z john.ellis@rsmart.com $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.metaobj.shared.mgt.impl;
21:
22: import java.util.ArrayList;
23: import java.util.Collection;
24: import java.util.Iterator;
25: import java.util.List;
26:
27: import org.sakaiproject.content.api.ContentHostingService;
28: import org.sakaiproject.content.api.ContentResource;
29: import org.sakaiproject.entity.api.ResourceProperties;
30: import org.sakaiproject.metaobj.shared.mgt.AgentManager;
31: import org.sakaiproject.metaobj.shared.mgt.IdManager;
32: import org.sakaiproject.metaobj.shared.mgt.HomeFactory;
33: import org.sakaiproject.metaobj.shared.mgt.home.StructuredArtifactHomeInterface;
34: import org.sakaiproject.metaobj.shared.model.*;
35:
36: /**
37: * Created by IntelliJ IDEA.
38: * User: John Ellis
39: * Date: Aug 17, 2005
40: * Time: 2:33:51 PM
41: * To change this template use File | Settings | File Templates.
42: */
43: public class StructuredArtifactFinder extends
44: WrappedStructuredArtifactFinder {
45:
46: private HomeFactory homeFactory;
47:
48: protected Artifact createArtifact(ContentResource resource) {
49: String formType = (String) resource.getProperties().get(
50: resource.getProperties().getNamePropStructObjType());
51:
52: StructuredArtifactHomeInterface home = (StructuredArtifactHomeInterface) getHomeFactory()
53: .getHome(formType);
54:
55: return home.load(resource);
56: }
57:
58: public HomeFactory getHomeFactory() {
59: return homeFactory;
60: }
61:
62: public void setHomeFactory(HomeFactory homeFactory) {
63: this .homeFactory = homeFactory;
64: }
65:
66: public Collection findByType(String type) {
67: List artifacts = getContentHostingService().findResources(type,
68: null, null);
69:
70: Collection returned = new ArrayList();
71:
72: for (Iterator i = artifacts.iterator(); i.hasNext();) {
73: ContentResource resource = (ContentResource) i.next();
74: returned.add(createArtifact(resource));
75: }
76:
77: return returned;
78: }
79:
80: }
|