This repository has been archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Requirement.java
695 lines (574 loc) · 17.8 KB
/
Requirement.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
/*
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompanies this distribution.
*
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-1.0 OR BSD-3-Clause
*/
package org.eclipse.lyo.oslc4j.client.resources;
import java.net.URI;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
import org.eclipse.lyo.oslc4j.core.annotation.OslcDescription;
import org.eclipse.lyo.oslc4j.core.annotation.OslcName;
import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace;
import org.eclipse.lyo.oslc4j.core.annotation.OslcOccurs;
import org.eclipse.lyo.oslc4j.core.annotation.OslcPropertyDefinition;
import org.eclipse.lyo.oslc4j.core.annotation.OslcRange;
import org.eclipse.lyo.oslc4j.core.annotation.OslcReadOnly;
import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape;
import org.eclipse.lyo.oslc4j.core.annotation.OslcTitle;
import org.eclipse.lyo.oslc4j.core.annotation.OslcValueType;
import org.eclipse.lyo.oslc4j.core.model.AbstractResource;
import org.eclipse.lyo.oslc4j.core.model.Link;
import org.eclipse.lyo.oslc4j.core.model.Occurs;
import org.eclipse.lyo.oslc4j.core.model.OslcConstants;
import org.eclipse.lyo.oslc4j.core.model.ValueType;
@Deprecated
@OslcNamespace(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE)
@OslcResourceShape(title = "Requirement Resource Shape", describes = RmConstants.TYPE_REQUIREMENT)
public class Requirement
extends AbstractResource
{
private String title;
private String description;
private String identifier;
private String shortTitle;
private final Set<String> subjects = new TreeSet<String>();
private final Set<URI> creators = new TreeSet<URI>();
private final Set<URI> contributors = new TreeSet<URI>();
private Date created;
private Date modified;
private final Set<URI> rdfTypes = new TreeSet<URI>();
private URI serviceProvider;
private URI instanceShape;
// OSLC Links
private final Set<Link> elaboratedBy = new HashSet<Link>();
private final Set<Link> elaborates = new HashSet<Link>();
private final Set<Link> specifiedBy = new HashSet<Link>();
private final Set<Link> specifies = new HashSet<Link>();
private final Set<Link> affectedBy = new HashSet<Link>();
private final Set<Link> trackedBy = new HashSet<Link>();
private final Set<Link> implementedBy = new HashSet<Link>();
private final Set<Link> validatedBy = new HashSet<Link>();
private final Set<Link> satisfiedBy = new HashSet<Link>();
private final Set<Link> satisfies = new HashSet<Link>();
private final Set<Link> decomposedBy = new HashSet<Link>();
private final Set<Link> decomposes = new HashSet<Link>();
private final Set<Link> constrainedBy = new HashSet<Link>();
private final Set<Link> constrains = new HashSet<Link>();
public Requirement()
{
super();
// Only add the type if Requirement is the created object
if ( ! ( this instanceof RequirementCollection ) ) {
rdfTypes.add(URI.create(RmConstants.TYPE_REQUIREMENT));
}
}
public Requirement(final URI about)
{
super(about);
// Only add the type if Requirement is the created object
if ( ! ( this instanceof RequirementCollection ) ) {
rdfTypes.add(URI.create(RmConstants.TYPE_REQUIREMENT));
}
}
public void addSubject(final String subject)
{
this.subjects.add(subject);
}
public void addConstrains(final Link constrains)
{
this.constrains.add(constrains);
}
public void addConstrainedBy(final Link constrainedBy)
{
this.constrainedBy.add(constrainedBy);
}
public void addDecomposes(final Link decomposes)
{
this.decomposes.add(decomposes);
}
public void addDecomposedBy(final Link decomposedBy)
{
this.decomposedBy.add(decomposedBy);
}
public void addSatisfies(final Link satisfies)
{
this.satisfies.add(satisfies);
}
public void addSatisfiedBy(final Link satisfiedBy)
{
this.satisfiedBy.add(satisfiedBy);
}
public void addValidatedBy(final Link validatedBy)
{
this.validatedBy.add(validatedBy);
}
public void addTrackedBy(final Link trackedBy)
{
this.trackedBy.add(trackedBy);
}
public void addImplementedBy(final Link implementedBy)
{
this.implementedBy.add(implementedBy);
}
public void addAffectedBy(final Link affectedBy)
{
this.affectedBy.add(affectedBy);
}
public void addElaboratedBy(final Link elaboratedBy)
{
this.elaboratedBy.add(elaboratedBy);
}
public void addElaborates(final Link elaborates)
{
this.elaborates.add(elaborates);
}
public void addSpecifiedBy(final Link specifiedBy)
{
this.specifiedBy.add(specifiedBy);
}
public void addSpecifies(final Link specifies)
{
this.specifies.add(specifies);
}
public void addContributor(final URI contributor)
{
this.contributors.add(contributor);
}
public void addCreator(final URI creator)
{
this.creators.add(creator);
}
public void addRdfType(final URI rdfType)
{
this.rdfTypes.add(rdfType);
}
@OslcDescription("Tag or keyword for a resource. Each occurrence of a dcterms:subject property denotes an additional tag for the resource.")
@OslcName("subject")
@OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "subject")
@OslcReadOnly(false)
@OslcTitle("Subjects")
public String[] getSubjects()
{
return subjects.toArray(new String[subjects.size()]);
}
@OslcDescription("The subject is elaborated by the object.")
@OslcName("elaboratedBy")
@OslcPropertyDefinition(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE + "elaboratedBy")
@OslcRange(RmConstants.TYPE_REQUIREMENT)
@OslcReadOnly(false)
@OslcTitle("Elaborated By")
public Link[] getElaboratedBy()
{
return elaboratedBy.toArray(new Link[elaboratedBy.size()]);
}
@OslcDescription("The object is elaborated by the subject.")
@OslcName("elaborates")
@OslcPropertyDefinition(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE + "elaborates")
@OslcRange(RmConstants.TYPE_REQUIREMENT)
@OslcReadOnly(false)
@OslcTitle("Elaborates")
public Link[] getElaborates()
{
return elaborates.toArray(new Link[elaborates.size()]);
}
@OslcDescription("The subject is specified by the object.")
@OslcName("specifiedBy")
@OslcPropertyDefinition(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE + "specifiedBy")
@OslcRange(RmConstants.TYPE_REQUIREMENT)
@OslcReadOnly(false)
@OslcTitle("Specified By")
public Link[] getSpecifiedBy()
{
return specifiedBy.toArray(new Link[specifiedBy.size()]);
}
@OslcDescription("The object is specified by the subject.")
@OslcName("specifies")
@OslcPropertyDefinition(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE + "specifies")
@OslcRange(RmConstants.TYPE_REQUIREMENT)
@OslcReadOnly(false)
@OslcTitle("Specifies")
public Link[] getSpecifies()
{
return specifies.toArray(new Link[specifies.size()]);
}
@OslcDescription("Resource, such as a change request, which implements this requirement.")
@OslcName("implementedBy")
@OslcPropertyDefinition(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE + "implementedBy")
@OslcRange(RmConstants.TYPE_REQUIREMENT)
@OslcReadOnly(false)
@OslcTitle("Implemented By")
public Link[] getImplementedBy()
{
return implementedBy.toArray(new Link[implementedBy.size()]);
}
@OslcDescription("Requirement is affected by a resource, such as a defect or issue.")
@OslcName("affectedBy")
@OslcPropertyDefinition(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE + "affectedBy")
@OslcRange(RmConstants.TYPE_REQUIREMENT)
@OslcReadOnly(false)
@OslcTitle("Affected By")
public Link[] getAffectedBy()
{
return affectedBy.toArray(new Link[affectedBy.size()]);
}
@OslcDescription("Resource, such as a change request, which tracks this requirement.")
@OslcName("trackedBy")
@OslcPropertyDefinition(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE + "trackedBy")
@OslcRange(RmConstants.TYPE_REQUIREMENT)
@OslcReadOnly(false)
@OslcTitle("tracked By")
public Link[] getTrackedBy()
{
return trackedBy.toArray(new Link[trackedBy.size()]);
}
@OslcDescription("Resource, such as a test case, which validates this requirement.")
@OslcName("validatedBy")
@OslcPropertyDefinition(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE + "validatedBy")
@OslcRange(RmConstants.TYPE_REQUIREMENT)
@OslcReadOnly(false)
@OslcTitle("Validated By")
public Link[] getValidatedBy()
{
return validatedBy.toArray(new Link[validatedBy.size()]);
}
@OslcDescription("The subject is satisfied by the object.")
@OslcName("satisfiedBy")
@OslcPropertyDefinition(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE + "satisfiedBy")
@OslcRange(RmConstants.TYPE_REQUIREMENT)
@OslcReadOnly(false)
@OslcTitle("Satisfied By")
public Link[] getSatisfiedBy()
{
return satisfiedBy.toArray(new Link[satisfiedBy.size()]);
}
@OslcDescription("The object is satisfied by the subject.")
@OslcName("satisfies")
@OslcPropertyDefinition(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE + "satisfies")
@OslcRange(RmConstants.TYPE_REQUIREMENT)
@OslcReadOnly(false)
@OslcTitle("Satisfies")
public Link[] getSatisfies()
{
return satisfies.toArray(new Link[satisfies.size()]);
}
@OslcDescription("The subject is decomposed by the object.")
@OslcName("decomposedBy")
@OslcPropertyDefinition(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE + "decomposedBy")
@OslcRange(RmConstants.TYPE_REQUIREMENT)
@OslcReadOnly(false)
@OslcTitle("DecomposedBy")
public Link[] getDecomposedBy()
{
return decomposedBy.toArray(new Link[decomposedBy.size()]);
}
@OslcDescription("The object is decomposed by the subject.")
@OslcName("decomposes")
@OslcPropertyDefinition(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE + "decomposes")
@OslcRange(RmConstants.TYPE_REQUIREMENT)
@OslcReadOnly(false)
@OslcTitle("Decomposes")
public Link[] getDecomposes()
{
return decomposes.toArray(new Link[decomposes.size()]);
}
@OslcDescription("The subject is constrained by the object.")
@OslcName("constrainedBy")
@OslcPropertyDefinition(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE + "constrainedBy")
@OslcRange(RmConstants.TYPE_REQUIREMENT)
@OslcReadOnly(false)
@OslcTitle("ConstrainedBy")
public Link[] getConstrainedBy()
{
return constrainedBy.toArray(new Link[constrainedBy.size()]);
}
@OslcDescription("The object is constrained by the subject.")
@OslcName("constrains")
@OslcPropertyDefinition(RmConstants.REQUIREMENTS_MANAGEMENT_NAMESPACE + "constrains")
@OslcRange(RmConstants.TYPE_REQUIREMENT)
@OslcReadOnly(false)
@OslcTitle("Constrains")
public Link[] getConstrains()
{
return constrains.toArray(new Link[constrains.size()]);
}
@OslcDescription("The person(s) who are responsible for the work needed to complete the change request.")
@OslcName("contributor")
@OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "contributor")
@OslcRange(RmConstants.TYPE_PERSON)
@OslcTitle("Contributors")
public URI[] getContributors()
{
return contributors.toArray(new URI[contributors.size()]);
}
@OslcDescription("Timestamp of resource creation.")
@OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "created")
@OslcReadOnly
@OslcTitle("Created")
public Date getCreated()
{
return created;
}
@OslcDescription("Creator or creators of resource.")
@OslcName("creator")
@OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "creator")
@OslcRange(RmConstants.TYPE_PERSON)
@OslcTitle("Creators")
public URI[] getCreators()
{
return creators.toArray(new URI[creators.size()]);
}
@OslcDescription("Descriptive text (reference: Dublin Core) about resource represented as rich text in XHTML content.")
@OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "description")
@OslcTitle("Description")
@OslcValueType(ValueType.XMLLiteral)
public String getDescription()
{
return description;
}
@OslcDescription("A unique identifier for a resource. Assigned by the service provider when a resource is created. Not intended for end-user display.")
@OslcOccurs(Occurs.ExactlyOne)
@OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "identifier")
@OslcReadOnly
@OslcTitle("Identifier")
public String getIdentifier()
{
return identifier;
}
@OslcDescription("Resource Shape that provides hints as to resource property value-types and allowed values. ")
@OslcPropertyDefinition(OslcConstants.OSLC_CORE_NAMESPACE + "instanceShape")
@OslcRange(OslcConstants.TYPE_RESOURCE_SHAPE)
@OslcTitle("Instance Shape")
public URI getInstanceShape()
{
return instanceShape;
}
@OslcDescription("Timestamp last latest resource modification.")
@OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "modified")
@OslcReadOnly
@OslcTitle("Modified")
public Date getModified()
{
return modified;
}
@OslcDescription("The resource type URIs.")
@OslcName("type")
@OslcPropertyDefinition(OslcConstants.RDF_NAMESPACE + "type")
@OslcTitle("Types")
public URI[] getRdfTypes()
{
return rdfTypes.toArray(new URI[rdfTypes.size()]);
}
@OslcDescription("The scope of a resource is a URI for the resource's OSLC Service Provider.")
@OslcPropertyDefinition(OslcConstants.OSLC_CORE_NAMESPACE + "serviceProvider")
@OslcRange(OslcConstants.TYPE_SERVICE_PROVIDER)
@OslcTitle("Service Provider")
public URI getServiceProvider()
{
return serviceProvider;
}
@OslcDescription("Short name identifying a resource, often used as an abbreviated identifier for presentation to end-users.")
@OslcPropertyDefinition(OslcConstants.OSLC_CORE_NAMESPACE + "shortTitle")
@OslcTitle("Short Title")
@OslcValueType(ValueType.XMLLiteral)
public String getShortTitle()
{
return shortTitle;
}
@OslcDescription("Title (reference: Dublin Core) or often a single line summary of the resource represented as rich text in XHTML content.")
@OslcOccurs(Occurs.ExactlyOne)
@OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "title")
@OslcTitle("Title")
@OslcValueType(ValueType.XMLLiteral)
public String getTitle()
{
return title;
}
public void setConstrains(final Link[] constrains)
{
this.constrains.clear();
if (constrains != null)
{
this.constrains.addAll(Arrays.asList(constrains));
}
}
public void setConstrainedBy(final Link[] constrainedBy)
{
this.constrainedBy.clear();
if (constrainedBy != null)
{
this.constrainedBy.addAll(Arrays.asList(constrainedBy));
}
}
public void setDecomposes(final Link[] decomposes)
{
this.affectedBy.clear();
if (decomposes != null)
{
this.decomposes.addAll(Arrays.asList(decomposes));
}
}
public void setDecomposedBy(final Link[] decomposedBy)
{
this.decomposedBy.clear();
if (decomposedBy != null)
{
this.decomposedBy.addAll(Arrays.asList(decomposedBy));
}
}
public void setSatisfies(final Link[] satisfies)
{
this.satisfies.clear();
if (satisfies != null)
{
this.satisfies.addAll(Arrays.asList(satisfies));
}
}
public void setSatisfiedBy(final Link[] satisfiedBy)
{
this.satisfiedBy.clear();
if (satisfiedBy != null)
{
this.satisfiedBy.addAll(Arrays.asList(satisfiedBy));
}
}
public void setValidatedBy(final Link[] validatedBy)
{
this.validatedBy.clear();
if (validatedBy != null)
{
this.validatedBy.addAll(Arrays.asList(validatedBy));
}
}
public void setTrackedBy(final Link[] trackedBy)
{
this.trackedBy.clear();
if (trackedBy != null)
{
this.trackedBy.addAll(Arrays.asList(trackedBy));
}
}
public void setAffectedBy(final Link[] affectedBy)
{
this.affectedBy.clear();
if (affectedBy != null)
{
this.affectedBy.addAll(Arrays.asList(affectedBy));
}
}
public void setImplementedBy(final Link[] implementedBy)
{
this.implementedBy.clear();
if (implementedBy != null)
{
this.implementedBy.addAll(Arrays.asList(implementedBy));
}
}
public void setElaboratedBy(final Link[] elaboratedBy)
{
this.elaboratedBy.clear();
if (elaboratedBy != null)
{
this.elaboratedBy.addAll(Arrays.asList(elaboratedBy));
}
}
public void setElaborates(final Link[] elaborates)
{
this.elaborates.clear();
if (elaborates != null)
{
this.elaborates.addAll(Arrays.asList(elaborates));
}
}
public void setSpecifiedBy(final Link[] specifiedBy)
{
this.specifiedBy.clear();
if (specifiedBy != null)
{
this.specifiedBy.addAll(Arrays.asList(specifiedBy));
}
}
public void setSpecifies(final Link[] specifies)
{
this.specifies.clear();
if (specifies != null)
{
this.specifies.addAll(Arrays.asList(specifies));
}
}
public void setContributors(final URI[] contributors)
{
this.contributors.clear();
if (contributors != null)
{
this.contributors.addAll(Arrays.asList(contributors));
}
}
public void setCreated(final Date created)
{
this.created = created;
}
public void setCreators(final URI[] creators)
{
this.creators.clear();
if (creators != null)
{
this.creators.addAll(Arrays.asList(creators));
}
}
public void setDescription(final String description)
{
this.description = description;
}
public void setIdentifier(final String identifier)
{
this.identifier = identifier;
}
public void setInstanceShape(final URI instanceShape)
{
this.instanceShape = instanceShape;
}
public void setModified(final Date modified)
{
this.modified = modified;
}
public void setRdfTypes(final URI[] rdfTypes)
{
this.rdfTypes.clear();
if (rdfTypes != null)
{
this.rdfTypes.addAll(Arrays.asList(rdfTypes));
}
}
public void setServiceProvider(final URI serviceProvider)
{
this.serviceProvider = serviceProvider;
}
public void setShortTitle(final String shortTitle)
{
this.shortTitle = shortTitle;
}
public void setTitle(final String title)
{
this.title = title;
}
public void setSubjects(final String[] subjects)
{
this.subjects.clear();
if (subjects != null)
{
this.subjects.addAll(Arrays.asList(subjects));
}
}
}