00001
00066 package com.arcle.rmt.superwaba.model.imp.rqml;
00067
00068 import superwaba.ext.xplat.io.Storable;
00069 import superwaba.ext.xplat.io.DataStream;
00070
00071 import com.arcle.rmt.xplat.util.List;
00072 import com.arcle.rmt.xplat.util.Iterator;
00073 import com.arcle.rmt.superwaba.model.imp.*;
00074 import com.arcle.rmt.rqml.*;
00075
00082 public class UsecaseImpl extends RQMLFirstClassImpl implements Usecase {
00083
00084 public UsecaseImpl() {
00085 actors = createList();
00086 preconditions = createList();
00087 postconditions = createList();
00088 normalCourse = createNormalCourseImpl();
00089 comment = createCommentImpl();
00090 alternativeCourses = createList();
00091 exceptions = createList();
00092 }
00093
00094
00095
00096
00097
00098 public Actor createActor() {
00099 Actor act = createActorImpl();
00100 actors.add(act);
00101 return act;
00102 }
00103
00104 public Precondition createPrecondition() {
00105 Precondition pre = createPreconditionImpl();
00106 preconditions.add(pre);
00107 return pre;
00108 }
00109
00110
00111 public Postcondition createPostcondition() {
00112 Postcondition post = createPostconditionImpl();
00113 postconditions.add(post);
00114 return post;
00115 }
00116
00117
00118 public AlternativeCourse createAlternativeCourse() {
00119 AlternativeCourse ac = createAlternativeCourseImpl();
00120 alternativeCourses.add(ac);
00121 return ac;
00122 }
00123
00124 public com.arcle.rmt.rqml.Exception createException() {
00125 com.arcle.rmt.rqml.Exception ex = createExceptionImpl();
00126 exceptions.add(ex);
00127 return ex;
00128 }
00129
00130 public Iterator getActors() {
00131 return actors.iterator();
00132 }
00133
00135 public Iterator getPreconditions() {
00136 return preconditions.iterator();
00137 }
00138
00140 public Iterator getPostconditions() {
00141 return postconditions.iterator();
00142 }
00143
00145 public NormalCourse getNormalCourse() {
00146 return normalCourse;
00147 }
00148
00150 public Iterator getAlternativeCourses() {
00151 return alternativeCourses.iterator();
00152 }
00153
00154
00156 public Iterator getExceptions() {
00157 return exceptions.iterator();
00158 }
00159
00161 public Comment getComment() {
00162 return comment;
00163 }
00164
00165
00166 public Actor getActor() {
00167 if (actors.size() == 0) {
00168 return createActor();
00169 } else {
00170 return (Actor) actors.get(0);
00171 }
00172 }
00173
00174
00175 public Precondition getPrecondition() {
00176 if (preconditions.size() == 0) {
00177 return createPrecondition();
00178 } else {
00179 return (Precondition) preconditions.get(0);
00180 }
00181 }
00182
00183
00184 public Postcondition getPostcondition() {
00185 if (postconditions.size() == 0) {
00186 return createPostcondition();
00187 } else {
00188 return (Postcondition) postconditions.get(0);
00189 }
00190 }
00191
00192 public com.arcle.rmt.rqml.Exception getException() {
00193 if (exceptions.size() == 0) {
00194 return createException();
00195 } else {
00196 return (com.arcle.rmt.rqml.Exception) exceptions.get(0);
00197 }
00198 }
00199
00200 public AlternativeCourse getAlternativeCourse() {
00201 if (alternativeCourses.size() == 0) {
00202 return createAlternativeCourse();
00203 } else {
00204 return (AlternativeCourse) alternativeCourses.get(0);
00205 }
00206 }
00207
00208
00209
00210
00211
00212 private List actors;
00213 private List preconditions;
00214 private List postconditions;
00215 private NormalCourseImpl normalCourse;
00216 private List alternativeCourses;
00217 private List exceptions;
00218 private CommentImpl comment;
00219
00220
00221
00222
00223 public GenericMemento createMemento() {
00224 return new Memento(this);
00225 }
00226
00227 protected ActorImpl createActorImpl() {
00228 return new ActorImpl();
00229 }
00230
00231 protected PreconditionImpl createPreconditionImpl() {
00232 return new PreconditionImpl();
00233 }
00234
00235 protected PostconditionImpl createPostconditionImpl() {
00236 return new PostconditionImpl();
00237 }
00238
00239 protected NormalCourseImpl createNormalCourseImpl() {
00240 return new NormalCourseImpl();
00241 }
00242
00243 protected AlternativeCourseImpl createAlternativeCourseImpl() {
00244 return new AlternativeCourseImpl();
00245 }
00246
00247
00248 protected ExceptionImpl createExceptionImpl() {
00249 return new ExceptionImpl();
00250 }
00251
00252 protected CommentImpl createCommentImpl() {
00253 return new CommentImpl();
00254 }
00255
00256
00257
00258
00259 protected static class Memento extends RQMLFirstClassImpl.Memento {
00260 public Memento(UsecaseImpl originator) {
00261 super(originator);
00262 }
00263
00264 public Storable getInstance() {
00265
00266
00267 return null;
00268 }
00269
00274 public void saveState(DataStream data) {
00275 super.saveState(data);
00276 final UsecaseImpl org = (UsecaseImpl) getOriginator();
00277 saveMementoable(org.normalCourse, data);
00278 saveMementoable(org.comment, data);
00279
00280 saveList(org.actors, data);
00281 saveList(org.preconditions, data);
00282 saveList(org.postconditions, data);
00283 saveList(org.alternativeCourses, data);
00284 saveList(org.exceptions, data);
00285
00286 }
00287
00288 public void loadState(DataStream data) {
00289 super.loadState(data);
00290 final UsecaseImpl org = (UsecaseImpl) getOriginator();
00291
00292 org.normalCourse = (NormalCourseImpl) loadMementoable(data,
00293 new MementoableFactory() {
00294 public Mementoable createOriginator() {
00295 return org.createNormalCourseImpl();
00296 }
00297 });
00298
00299 org.comment = (CommentImpl) loadMementoable(data,
00300 new MementoableFactory() {
00301 public Mementoable createOriginator() {
00302 return org.createCommentImpl();
00303 }
00304 });
00305
00306 org.actors = loadList(data, new MementoableFactory() {
00307 public Mementoable createOriginator() {
00308 return org.createActorImpl();
00309 }
00310 });
00311
00312 org.preconditions = loadList(data, new MementoableFactory() {
00313 public Mementoable createOriginator() {
00314 return org.createPreconditionImpl();
00315 }
00316 });
00317
00318 org.postconditions = loadList(data, new MementoableFactory() {
00319 public Mementoable createOriginator() {
00320 return org.createPostconditionImpl();
00321 }
00322 });
00323
00324 org.alternativeCourses = loadList(data, new MementoableFactory() {
00325 public Mementoable createOriginator() {
00326 return org.createAlternativeCourseImpl();
00327 }
00328 });
00329
00330 org.exceptions = loadList(data, new MementoableFactory() {
00331 public Mementoable createOriginator() {
00332 return org.createExceptionImpl();
00333 }
00334 });
00335
00336 }
00337
00338
00339 public byte getID() {
00340 return DocumentImpl.USECASE_ID;
00341 }
00342 }
00343 }