-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOrganizationReference.cs
More file actions
172 lines (151 loc) · 5.29 KB
/
Copy pathOrganizationReference.cs
File metadata and controls
172 lines (151 loc) · 5.29 KB
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
// <copyright file="MetricManager.cs" company="Credential Engine">
// Copyright (c) Credential Engine. All rights reserved.
// </copyright>
// <license>Apache License 2.0 - https://www.apache.org/licenses/LICENSE-2.0</license>
using Newtonsoft.Json;
using System.Collections.Generic;
namespace RA.Models.Input
{
/// <summary>
/// Class for handling references to an organization
/// Either the Id as an resolvable URL, a CTID (that will be use to format the Id as a URI) or provide all of the properities:
/// - Type
/// - Name
/// - Description
/// - Subject webpage
/// - Social media
/// 2020-07-01 With the addition of many additional properties to EntityReference, changed OrganizationReference to no lonber inherit from EntityReference.
/// </summary>
public class OrganizationReference
{
public static string CredentialOrganization = "CredentialOrganization";
public static string QACredentialOrganization = "QACredentialOrganization";
/// <summary>
/// The type of organization is one of :
/// - CredentialOrganization
/// - QACredentialOrganization
/// Required
/// </summary>
public string Type { get; set; }
/// <summary>
/// Type of CTDL object
/// </summary>
[JsonProperty( "@type" )]
public string CtdlType { get; set; }
/// <summary>
/// Id is a resovable URI
/// If the entity exists in the registry, provide the URI.
/// If not sure of the exact URI, especially if just publishing the entity, then provide the CTID and the API will format the URI.
/// Alterate URIs are under consideration. For example
/// http://dbpedia.com/Stanford_University
/// </summary>
public string Id { get; set; }
/// <summary>
/// Handle both forms of input for type
/// </summary>
[JsonProperty( "@id" )]
public string AtId { get; set; }
/// <summary>
/// Optionally, a CTID can be entered instead of an Id.
/// A CTID is recommended for flexibility.
/// Only enter Id or CTID, but not both.
/// </summary>
public string CTID { get; set; }
/// <summary>
/// Name of the entity (required)
/// </summary>
public string Name { get; set; }
/// <summary>
/// LanguageMap for Name
/// </summary>
[JsonProperty( PropertyName = "ceterms:name" )]
public LanguageMap NameLangMap { get; set; } = null;
/// <summary>
/// Subject webpage of the entity (required)
/// This should be for the referenced entity.
/// For example, if the reference is for an organization, the subject webpage should be on the organization site.
/// </summary>
public string SubjectWebpage { get; set; }
/// <summary>
/// Description of the entity (optional)
/// Minimum of 15 characters when present, but should be clear.
/// This should be the general description of the entity.
/// For example, for an organization, the description should be about the organization specifically not, how the organization is related to, or interacts with the refering entity.
/// </summary>
public string Description { get; set; }
/// <summary>
/// Alternately can provide a language map
/// </summary>
[JsonProperty( PropertyName = "ceterms:description" )]
public LanguageMap DescriptionLangMap { get; set; } = null;
/// <summary>
/// Social Media URL links
/// For example, Facebook, LinkedIn
/// </summary>
public List<string> SocialMedia { get; set; } // URL
/// <summary>
/// Alphanumeric token that identifies this resource and information about the token's originating context or scheme.
/// <see cref="https://purl.org/ctdl/terms/identifier"/>
/// ceterms:identifier
/// </summary>
public List<IdentifierValue> Identifier { get; set; } = new List<IdentifierValue>();
// additional optional information - why not everything!
/// <summary>
/// List of Places
/// In this context - an organization reference, partial addresses are allowed.
/// This means a street address and/or a postal would not be required, just say city, region, and country
/// </summary>
public List<Place> Address { get; set; } = new List<Place>();
/// <summary>
/// Listing of online and/or physical locations
/// List of URLs
/// </summary>
public List<string> AvailabilityListing { get; set; } = new List<string>();
/// <summary>
/// List of email addresses
/// </summary>
public List<string> Email { get; set; } = new List<string>();
/// <summary>
/// check if has the necessary properties
/// </summary>
/// <returns></returns>
public bool HasNecessaryProperties()
{
// skip social media for now
// || ( SocialMedia == null || SocialMedia.Count == 0 )
// || string.IsNullOrWhiteSpace( Description )
if ( string.IsNullOrWhiteSpace( Type )
|| ( string.IsNullOrWhiteSpace( Name ) && ( NameLangMap == null || NameLangMap.Count == 0 ) )
|| string.IsNullOrWhiteSpace( SubjectWebpage )
)
{
return false;
}
else
{
return true;
}
}
/// <summary>
/// Purpose is to determine if class has data
/// </summary>
/// <returns></returns>
public bool IsEmpty()
{
if ( string.IsNullOrWhiteSpace( Id )
&& string.IsNullOrWhiteSpace( Name )
&& string.IsNullOrWhiteSpace( CTID )
&& string.IsNullOrWhiteSpace( Description )
&& string.IsNullOrWhiteSpace( SubjectWebpage )
&& ( SocialMedia == null || SocialMedia.Count == 0 )
)
{
return true;
}
else
{
return false;
}
}
}
}