1 package org.apache.maven.archiva.database.jdo;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.maven.archiva.database.ArchivaDatabaseException;
23 import org.apache.maven.archiva.database.Constraint;
24 import org.apache.maven.archiva.database.ObjectNotFoundException;
25 import org.apache.maven.archiva.database.ProjectModelDAO;
26 import org.apache.maven.archiva.model.ArchivaProjectModel;
27 import org.apache.maven.archiva.model.jpox.ArchivaProjectModelKey;
29 import java.util.List;
36 * @plexus.component role-hint="jdo"
38 public class JdoProjectModelDAO
39 implements ProjectModelDAO
42 * @plexus.requirement role-hint="archiva"
44 private JdoAccess jdo;
46 public ArchivaProjectModel createProjectModel( String groupId, String artifactId, String version )
48 ArchivaProjectModel model;
52 model = getProjectModel( groupId, artifactId, version );
54 catch ( ArchivaDatabaseException e )
56 model = new ArchivaProjectModel();
57 model.setGroupId( groupId );
58 model.setArtifactId( artifactId );
59 model.setVersion( version );
65 public ArchivaProjectModel getProjectModel( String groupId, String artifactId, String version )
66 throws ObjectNotFoundException, ArchivaDatabaseException
68 ArchivaProjectModelKey key = new ArchivaProjectModelKey();
69 key.groupId = groupId;
70 key.artifactId = artifactId;
71 key.version = version;
73 return (ArchivaProjectModel) jdo.getObjectById( ArchivaProjectModel.class, key, null );
76 public List<ArchivaProjectModel> queryProjectModels( Constraint constraint )
77 throws ObjectNotFoundException, ArchivaDatabaseException
79 return jdo.queryObjects( ArchivaProjectModel.class, constraint );
82 public ArchivaProjectModel saveProjectModel( ArchivaProjectModel model )
83 throws ArchivaDatabaseException
85 return (ArchivaProjectModel) jdo.saveObject( model );
88 public void deleteProjectModel( ArchivaProjectModel model )
89 throws ArchivaDatabaseException
91 jdo.removeObject( model );