001/**
002 *  Licensed to the Apache Software Foundation (ASF) under one or more
003 *  contributor license agreements.  See the NOTICE file distributed with
004 *  this work for additional information regarding copyright ownership.
005 *  The ASF licenses this file to You under the Apache License, Version 2.0
006 *  (the "License"); you may not use this file except in compliance with
007 *  the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 *  Unless required by applicable law or agreed to in writing, software
012 *  distributed under the License is distributed on an "AS IS" BASIS,
013 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 *  See the License for the specific language governing permissions and
015 *  limitations under the License.
016 */
017package org.apache.isis.core.metamodel.adapter;
018
019import java.util.List;
020
021import org.apache.isis.applib.services.bookmark.Bookmark;
022import org.apache.isis.core.commons.components.Injectable;
023import org.apache.isis.core.commons.config.IsisConfiguration;
024import org.apache.isis.core.metamodel.adapter.oid.AggregatedOid;
025import org.apache.isis.core.metamodel.adapter.oid.Oid;
026import org.apache.isis.core.metamodel.runtimecontext.RuntimeContextAbstract;
027import org.apache.isis.core.metamodel.spec.ObjectSpecification;
028
029public interface DomainObjectServices extends Injectable {
030
031    // ///////////////////////////////////////////
032    // Instantiate
033    // ///////////////////////////////////////////
034
035    /**
036     * Provided by the <tt>PersistenceSession</tt> when used by framework.
037     * 
038     * <p>
039     * Called by <tt>DomainObjectContainerDefault</tt>.
040     */
041    ObjectAdapter createTransientInstance(ObjectSpecification spec);
042
043    ObjectAdapter createViewModelInstance(ObjectSpecification spec, String memento);
044
045    /**
046     * Create an instance of an aggregated object that will be persisted within the
047     * parent adapter.
048     * 
049     * <p>
050     * The {@link Oid} of the returned {@link ObjectAdapter adapter} will be of type
051     * {@link AggregatedOid}.  The oid's {@link AggregatedOid#getLocalId() localId}
052     * is generated as per the configured objectstore (<tt>OidGenerator</tt>).
053     * 
054     * <p>
055     * Called by <tt>DomainObjectContainerDefault</tt>.
056     */
057    ObjectAdapter createAggregatedInstance(ObjectSpecification spec, ObjectAdapter parent);
058
059    void injectServicesInto(Object domainObject);
060    
061    // ///////////////////////////////////////////
062    // retrieve
063    // ///////////////////////////////////////////
064
065    /**
066     * Provided by <tt>PersistenceSession</tt> when used by framework.
067     * 
068     * <p>
069     * Called by <tt>DomainObjectContainerDefault</tt>.
070     */
071    void resolve(Object parent);
072
073    /**
074     * Provided by <tt>PersistenceSession</tt> when used by framework.
075     * 
076     * <p>
077     * Called by <tt>DomainObjectContainerDefault</tt>.
078     */
079    void resolve(Object parent, Object field);
080
081    /**
082     * Provided by <tt>PersistenceSession</tt> when used by framework.
083     * 
084     * <p>
085     * Called by <tt>BookmarkServicesDefault</tt>.
086     * @return 
087     */
088    Object lookup(Bookmark bookmark);
089
090    Bookmark bookmarkFor(Object domainObject);
091
092    Bookmark bookmarkFor(Class<?> cls, String identifier);
093
094    
095    // ///////////////////////////////////////////
096    // flush, commit
097    // ///////////////////////////////////////////
098
099    /**
100     * Provided by <tt>TransactionManager</tt> when used by framework.
101     * 
102     * <p>
103     * Called by <tt>DomainObjectContainerDefault</tt>.
104     */
105    boolean flush();
106
107    /**
108     * Provided by <tt>TransactionManager</tt> when used by framework.
109     * 
110     * <p>
111     * Called by <tt>DomainObjectContainerDefault</tt>.
112     */
113    void commit();
114
115    // //////////////////////////////////////////////////////////////////
116    // info, warn, error messages
117    // //////////////////////////////////////////////////////////////////
118
119    /**
120     * Provided by <tt>MessageBroker</tt> when used by framework.
121     * 
122     * <p>
123     * Called by <tt>DomainObjectContainerDefault</tt>.
124     */
125    void informUser(String message);
126
127    /**
128     * Provided by <tt>MessageBroker</tt> when used by framework.
129     * 
130     * <p>
131     * Called by <tt>DomainObjectContainerDefault</tt>.
132     */
133    void warnUser(String message);
134
135    /**
136     * Provided by <tt>MessageBroker</tt> when used by framework.
137     * 
138     * <p>
139     * Called by <tt>DomainObjectContainerDefault</tt>.
140     */
141    void raiseError(String message);
142
143    // //////////////////////////////////////////////////////////////////
144    // properties
145    // //////////////////////////////////////////////////////////////////
146
147    /**
148     * Provided by {@link RuntimeContextAbstract} itself, cloned properties from
149     * {@link IsisConfiguration}.
150     * 
151     * <p>
152     * Called by <tt>DomainObjectContainerDefault</tt>.
153     */
154    String getProperty(String name);
155
156    /**
157     * Provided by {@link RuntimeContextAbstract} itself, cloned properties from
158     * {@link IsisConfiguration}.
159     * 
160     * <p>
161     * Called by <tt>DomainObjectContainerDefault</tt>.
162     */
163    List<String> getPropertyNames();
164
165
166
167
168}