use of org.openmuc.jasn1.compiler.modules.module1.Name in project ORCID-Source by ORCID.
the class RDFWriterTest method fakeBio.
private Record fakeBio() throws DatatypeConfigurationException {
Record r = new Record();
r.setOrcidIdentifier(new OrcidIdentifier());
r.getOrcidIdentifier().setPath("000-1337");
r.getOrcidIdentifier().setUri("http://orcid.example.com/000-1337");
r.setHistory(new History());
r.getHistory().setCreationMethod(CreationMethod.WEBSITE);
XMLGregorianCalendar value = dataTypeFactory.newXMLGregorianCalendar(1980, 12, 31, 23, 29, 29, 999, 0);
r.getHistory().setLastModifiedDate(new LastModifiedDate(value));
r.getHistory().setClaimed(true);
r.setPerson(new Person());
r.getPerson().setBiography(new Biography());
r.getPerson().setName(new Name());
r.getPerson().getName().setFamilyName(new FamilyName("Doe"));
r.getPerson().getName().setCreditName(new CreditName("John F Doe"));
r.getPerson().getName().setGivenNames(new GivenNames("John"));
r.getPerson().setOtherNames(new OtherNames());
r.getPerson().getOtherNames().setOtherNames(new ArrayList<OtherName>());
OtherName n = new OtherName();
n.setContent("Johnny");
n.setVisibility(Visibility.PUBLIC);
OtherName n1 = new OtherName();
n1.setContent("Mr Doe");
n1.setVisibility(Visibility.PUBLIC);
r.getPerson().getOtherNames().getOtherNames().add(n);
r.getPerson().getOtherNames().getOtherNames().add(n1);
r.getPerson().setResearcherUrls(new ResearcherUrls());
r.getPerson().getResearcherUrls().setResearcherUrls(new ArrayList<ResearcherUrl>());
ResearcherUrl anonymous = new ResearcherUrl();
anonymous.setUrl(new Url("http://example.com/anon"));
anonymous.setVisibility(Visibility.PUBLIC);
r.getPerson().getResearcherUrls().getResearcherUrls().add(anonymous);
r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/myPage", "homePage"));
r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/foaf#me", "FOAF"));
r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/webId", "webID"));
r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/other", "other"));
r.getPerson().setAddresses(new Addresses());
r.getPerson().getAddresses().setAddress(new ArrayList<Address>());
Address a = new Address();
a.setCountry(new Country());
a.getCountry().setValue(Iso3166Country.GB);
r.getPerson().getAddresses().getAddress().add(a);
r.getPerson().setEmails(new Emails());
r.getPerson().getEmails().setEmails(new ArrayList<Email>());
Email e = new Email();
e.setEmail("john@example.org");
e.setCurrent(true);
Email e1 = new Email();
e1.setEmail("doe@example.com");
e1.setCurrent(true);
r.getPerson().getEmails().getEmails().add(e);
r.getPerson().getEmails().getEmails().add(e1);
return r;
}
use of org.openmuc.jasn1.compiler.modules.module1.Name in project ORCID-Source by ORCID.
the class RecordTest method testViewRecordFromMemberAPI.
@Test
public void testViewRecordFromMemberAPI() throws InterruptedException, JSONException {
String accessToken = getAccessToken();
assertNotNull(accessToken);
ClientResponse response = memberV2ApiClient.viewRecord(getUser1OrcidId(), accessToken);
assertNotNull(response);
assertEquals("invalid " + response, 200, response.getStatus());
Record record = response.getEntity(Record.class);
assertNotNull(record);
assertNotNull(record.getOrcidIdentifier());
assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
// Check the visibility of every activity that exists
if (record.getActivitiesSummary() != null) {
// Educations
if (record.getActivitiesSummary().getEducations() != null) {
Educations e = record.getActivitiesSummary().getEducations();
if (e.getSummaries() != null) {
for (EducationSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
// Employments
if (record.getActivitiesSummary().getEmployments() != null) {
Employments e = record.getActivitiesSummary().getEmployments();
if (e.getSummaries() != null) {
for (EmploymentSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
// Fundings
if (record.getActivitiesSummary().getFundings() != null) {
Fundings f = record.getActivitiesSummary().getFundings();
List<FundingGroup> groups = f.getFundingGroup();
if (groups != null) {
for (FundingGroup fGroup : groups) {
List<FundingSummary> summaries = fGroup.getFundingSummary();
if (summaries != null) {
for (FundingSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
// PeerReviews
if (record.getActivitiesSummary().getPeerReviews() != null) {
PeerReviews p = record.getActivitiesSummary().getPeerReviews();
List<PeerReviewGroup> groups = p.getPeerReviewGroup();
if (groups != null) {
for (PeerReviewGroup pGroup : groups) {
List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
if (summaries != null) {
for (PeerReviewSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
// Works
if (record.getActivitiesSummary().getWorks() != null) {
Works w = record.getActivitiesSummary().getWorks();
List<WorkGroup> groups = w.getWorkGroup();
if (groups != null) {
for (WorkGroup wGroup : groups) {
List<WorkSummary> summaries = wGroup.getWorkSummary();
if (summaries != null) {
for (WorkSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
}
// Check the visibility of every biography elements that exists
if (record.getPerson() != null) {
// Address
if (record.getPerson().getAddresses() != null) {
Addresses addresses = record.getPerson().getAddresses();
List<Address> list = addresses.getAddress();
if (list != null) {
for (Address o : list) {
assertNotNull(o.getSource());
assertNotNull(o.getVisibility());
Visibility v = o.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), o.getSource().retrieveSourcePath());
}
}
}
}
// Biography
if (record.getPerson().getBiography() != null) {
Biography b = record.getPerson().getBiography();
if (b != null) {
assertNotNull(b.getVisibility());
if (Visibility.PRIVATE.equals(b.getVisibility())) {
fail("Visibility is private");
}
}
}
// Emails
if (record.getPerson().getEmails() != null) {
Emails emails = record.getPerson().getEmails();
List<Email> list = emails.getEmails();
if (list != null) {
for (Email e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
fail("Email " + e.getEmail() + " is private");
}
}
}
}
// External identifiers
if (record.getPerson().getExternalIdentifiers() != null) {
PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
if (list != null) {
for (PersonExternalIdentifier e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
// Keywords
if (record.getPerson().getKeywords() != null) {
Keywords keywords = record.getPerson().getKeywords();
List<Keyword> list = keywords.getKeywords();
if (list != null) {
for (Keyword e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
// Name
if (record.getPerson().getName() != null) {
Name name = record.getPerson().getName();
if (Visibility.PRIVATE.equals(name.getVisibility())) {
fail("Name is private");
}
}
// Other names
if (record.getPerson().getOtherNames() != null) {
OtherNames otherNames = record.getPerson().getOtherNames();
List<OtherName> list = otherNames.getOtherNames();
if (list != null) {
for (OtherName e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
// Researcher urls
if (record.getPerson().getResearcherUrls() != null) {
ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
List<ResearcherUrl> list = rUrls.getResearcherUrls();
if (list != null) {
for (ResearcherUrl e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
}
}
use of org.openmuc.jasn1.compiler.modules.module1.Name in project ORCID-Source by ORCID.
the class RecordTest method testViewRecordFromMemberAPI.
@Test
public void testViewRecordFromMemberAPI() throws InterruptedException, JSONException {
String accessToken = getAccessToken();
assertNotNull(accessToken);
ClientResponse response = memberV2ApiClient.viewRecord(getUser1OrcidId(), accessToken);
assertNotNull(response);
assertEquals("invalid " + response, 200, response.getStatus());
Record record = response.getEntity(Record.class);
assertNotNull(record);
assertNotNull(record.getOrcidIdentifier());
assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
// Check the visibility of every activity that exists
if (record.getActivitiesSummary() != null) {
// Educations
if (record.getActivitiesSummary().getEducations() != null) {
Educations e = record.getActivitiesSummary().getEducations();
if (e.getSummaries() != null) {
for (EducationSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
// Employments
if (record.getActivitiesSummary().getEmployments() != null) {
Employments e = record.getActivitiesSummary().getEmployments();
if (e.getSummaries() != null) {
for (EmploymentSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
// Fundings
if (record.getActivitiesSummary().getFundings() != null) {
Fundings f = record.getActivitiesSummary().getFundings();
List<FundingGroup> groups = f.getFundingGroup();
if (groups != null) {
for (FundingGroup fGroup : groups) {
List<FundingSummary> summaries = fGroup.getFundingSummary();
if (summaries != null) {
for (FundingSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
// PeerReviews
if (record.getActivitiesSummary().getPeerReviews() != null) {
PeerReviews p = record.getActivitiesSummary().getPeerReviews();
List<PeerReviewGroup> groups = p.getPeerReviewGroup();
if (groups != null) {
for (PeerReviewGroup pGroup : groups) {
List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
if (summaries != null) {
for (PeerReviewSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
// Works
if (record.getActivitiesSummary().getWorks() != null) {
Works w = record.getActivitiesSummary().getWorks();
List<WorkGroup> groups = w.getWorkGroup();
if (groups != null) {
for (WorkGroup wGroup : groups) {
List<WorkSummary> summaries = wGroup.getWorkSummary();
if (summaries != null) {
for (WorkSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
}
// Check the visibility of every biography elements that exists
if (record.getPerson() != null) {
// Address
if (record.getPerson().getAddresses() != null) {
Addresses addresses = record.getPerson().getAddresses();
List<Address> list = addresses.getAddress();
if (list != null) {
for (Address o : list) {
assertNotNull(o.getSource());
assertNotNull(o.getVisibility());
Visibility v = o.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), o.getSource().retrieveSourcePath());
}
}
}
}
// Biography
if (record.getPerson().getBiography() != null) {
Biography b = record.getPerson().getBiography();
if (b != null) {
assertNotNull(b.getVisibility());
if (Visibility.PRIVATE.equals(b.getVisibility())) {
fail("Visibility is private");
}
}
}
// Emails
if (record.getPerson().getEmails() != null) {
Emails emails = record.getPerson().getEmails();
List<Email> list = emails.getEmails();
if (list != null) {
for (Email e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
fail("Email " + e.getEmail() + " is private");
}
}
}
}
// External identifiers
if (record.getPerson().getExternalIdentifiers() != null) {
PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
if (list != null) {
for (PersonExternalIdentifier e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
// Keywords
if (record.getPerson().getKeywords() != null) {
Keywords keywords = record.getPerson().getKeywords();
List<Keyword> list = keywords.getKeywords();
if (list != null) {
for (Keyword e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
// Name
if (record.getPerson().getName() != null) {
Name name = record.getPerson().getName();
if (Visibility.PRIVATE.equals(name.getVisibility())) {
fail("Name is private");
}
}
// Other names
if (record.getPerson().getOtherNames() != null) {
OtherNames otherNames = record.getPerson().getOtherNames();
List<OtherName> list = otherNames.getOtherNames();
if (list != null) {
for (OtherName e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
// Researcher urls
if (record.getPerson().getResearcherUrls() != null) {
ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
List<ResearcherUrl> list = rUrls.getResearcherUrls();
if (list != null) {
for (ResearcherUrl e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
}
}
use of org.openmuc.jasn1.compiler.modules.module1.Name in project ORCID-Source by ORCID.
the class RecordTest method testViewRecordFromPublicAPI.
@Test
public void testViewRecordFromPublicAPI() {
ClientResponse response = publicV2ApiClient.viewRecordXML(getUser1OrcidId());
assertNotNull(response);
assertEquals("invalid " + response, 200, response.getStatus());
Record record = response.getEntity(Record.class);
assertNotNull(record);
assertNotNull(record.getOrcidIdentifier());
assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
// Check the visibility of every activity that exists
if (record.getActivitiesSummary() != null) {
if (record.getActivitiesSummary() != null) {
// Educations
if (record.getActivitiesSummary().getEducations() != null) {
Educations e = record.getActivitiesSummary().getEducations();
if (e.getSummaries() != null) {
for (EducationSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
// Employments
if (record.getActivitiesSummary().getEmployments() != null) {
Employments e = record.getActivitiesSummary().getEmployments();
if (e.getSummaries() != null) {
for (EmploymentSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
// Fundings
if (record.getActivitiesSummary().getFundings() != null) {
Fundings f = record.getActivitiesSummary().getFundings();
List<FundingGroup> groups = f.getFundingGroup();
if (groups != null) {
for (FundingGroup fGroup : groups) {
List<FundingSummary> summaries = fGroup.getFundingSummary();
if (summaries != null) {
for (FundingSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
// PeerReviews
if (record.getActivitiesSummary().getPeerReviews() != null) {
PeerReviews p = record.getActivitiesSummary().getPeerReviews();
List<PeerReviewGroup> groups = p.getPeerReviewGroup();
if (groups != null) {
for (PeerReviewGroup pGroup : groups) {
List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
if (summaries != null) {
for (PeerReviewSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
// Works
if (record.getActivitiesSummary().getWorks() != null) {
Works w = record.getActivitiesSummary().getWorks();
List<WorkGroup> groups = w.getWorkGroup();
if (groups != null) {
for (WorkGroup wGroup : groups) {
List<WorkSummary> summaries = wGroup.getWorkSummary();
if (summaries != null) {
for (WorkSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
}
}
// Check the visibility of every biography elements that exists
if (record.getPerson() != null) {
// Address
if (record.getPerson().getAddresses() != null) {
Addresses addresses = record.getPerson().getAddresses();
List<Address> list = addresses.getAddress();
if (list != null) {
for (Address o : list) {
assertNotNull(o.getSource());
assertEquals(Visibility.PUBLIC, o.getVisibility());
}
}
}
// Biography
if (record.getPerson().getBiography() != null) {
Biography b = record.getPerson().getBiography();
if (b != null) {
assertNotNull(b.getVisibility());
assertEquals(Visibility.PUBLIC, b.getVisibility());
}
}
// Emails
if (record.getPerson().getEmails() != null) {
Emails emails = record.getPerson().getEmails();
List<Email> list = emails.getEmails();
if (list != null) {
for (Email e : list) {
assertNotNull(e.getVisibility());
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
// External identifiers
if (record.getPerson().getExternalIdentifiers() != null) {
PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
if (list != null) {
for (PersonExternalIdentifier e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
// Keywords
if (record.getPerson().getKeywords() != null) {
Keywords keywords = record.getPerson().getKeywords();
List<Keyword> list = keywords.getKeywords();
if (list != null) {
for (Keyword e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
// Name
if (record.getPerson().getName() != null) {
Name name = record.getPerson().getName();
assertEquals(Visibility.PUBLIC, name.getVisibility());
}
// Other names
if (record.getPerson().getOtherNames() != null) {
OtherNames otherNames = record.getPerson().getOtherNames();
List<OtherName> list = otherNames.getOtherNames();
if (list != null) {
for (OtherName e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
// Researcher urls
if (record.getPerson().getResearcherUrls() != null) {
ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
List<ResearcherUrl> list = rUrls.getResearcherUrls();
if (list != null) {
for (ResearcherUrl e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
}
}
use of org.openmuc.jasn1.compiler.modules.module1.Name in project CIM-Identities by epri-dev.
the class CIMWebService method submitData.
// Method name: submitData
// Parameters: n_nameNew, nt_nameNew, nt_desNew, nta_nameNew, nta_desNew, mRID, action, gen_uuidSel
// Purpose: Submits data for either insertion, deletion, or modification
public String submitData(String n_nameNew, String nt_nameNew, String nt_desNew, String nta_nameNew, String nta_desNew, String mRID, String action, boolean gen_uuidSel) {
ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesEventMessageType msg = new ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesEventMessageType();
ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesResponseMessageType resp = new ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesResponseMessageType();
CIMIdentitiesPayloadType payload = new CIMIdentitiesPayloadType();
CIMIdentities cimids = new CIMIdentities();
CIMIdentity cimid = new CIMIdentity();
payload.setCIMIdentities(cimids);
ArrayList<CIMIdentity> cim = (ArrayList<CIMIdentity>) payload.getCIMIdentities().getCIMIdentity();
IdentifiedObject value = new IdentifiedObject();
value.setMRID(mRID);
cimid.setIdentifiedObject(value);
String error = new String();
Name name = new Name();
name.setName(n_nameNew);
if (action.equals("delete"))
name.setName("");
if (name.getName() == null)
name.setName("");
cimid.getNames().add(name);
// set NameType name/description
NameType nameType = new NameType();
nameType.setDescription(nt_desNew);
if (action.equals("delete"))
nameType.setDescription("");
if (nameType.getDescription() == null)
nameType.setDescription("");
nameType.setName(nt_nameNew);
if (action.equals("delete"))
nameType.setName("");
if (nameType.getName() == null)
nameType.setName("");
cimid.getNames().get(0).setNameType(nameType);
// set NameTypeAuthority name/description
NameTypeAuthority nameTypeAuth = new NameTypeAuthority();
nameTypeAuth.setDescription(nta_desNew);
if (action.equals("delete"))
nameTypeAuth.setDescription("");
if (nameTypeAuth.getDescription() == null)
nameTypeAuth.setDescription("");
nameTypeAuth.setName(nta_nameNew);
if (action.equals("delete"))
nameTypeAuth.setName("");
if (nameTypeAuth.getName() == null)
nameTypeAuth.setDescription("");
cimid.getNames().get(0).getNameType().setNameTypeAuthority(nameTypeAuth);
cim.add(cimid);
msg.setPayload(payload);
/* Insertion handling */
if (action.equals("insert")) {
if (gen_uuidSel == true) {
value.setMRID("");
payload.getCIMIdentities().getCIMIdentity().get(0).setIdentifiedObject(value);
msg.setPayload(payload);
}
HeaderType header = new HeaderType();
header.setNoun("CIMIdentities");
header.setVerb("create");
msg.setHeader(header);
try {
resp = createdCIMIdentitiesRequest(msg);
String confirmation = "Data inserted:<br>" + "<br><strong>Name:</strong> " + resp.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getName() + "<br><strong>NameType Name:</strong> " + resp.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getName() + "<br><strong>NameType Description:</strong> " + resp.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getDescription() + "<br><strong>NameTypeAuthority Name:</strong> " + resp.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getName() + "<br><strong>NameTypeAuthority Description:</strong> " + resp.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getDescription() + "<br><strong>mRID:</strong> " + resp.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().getMRID();
return confirmation;
} catch (FaultMessage ex) {
resp.getReply().getError().get(0).setDetails(ex.getMessage());
return resp.getReply().getError().get(0).getDetails();
}
} else /* deletion handling */
if (action.equals("delete") && gen_uuidSel == true) {
uuidEntered = true;
HeaderType header = new HeaderType();
header.setNoun("CIMIdentities");
header.setVerb("delete");
msg.setHeader(header);
/* query the server for the mRID being deleted */
CIMIdentitiesQueriesRequestType request = new CIMIdentitiesQueriesRequestType();
CIMIdentitiesQueries var = new CIMIdentitiesQueries();
EndDeviceGroup edg = new EndDeviceGroup();
// can be null, '?', or '""' to receive all data, else set mRID
edg.setMRID(mRID);
message.setRequest(request);
message.getRequest().setCIMIdentitiesQueries(var);
message.getRequest().getCIMIdentitiesQueries().getEndDeviceGroup().add(0, edg);
message.getRequest().getCIMIdentitiesQueries().getEndDeviceGroup();
try {
response = queryCIMIdentities(message);
} catch (QueryCIMIdentitiesFaultMessage ex) {
return ex.getMessage();
}
/* set outgoing deletion message to contain ALL data about the mRID */
msg.getPayload().setCIMIdentities(response.getPayload().getCIMIdentities());
try {
if (response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().getMRID() == null)
throw new IndexOutOfBoundsException("mRID doesn't exist");
deletedCIMIdentitiesRequest(msg);
String confirmation = "Data deleted:<br>" + "<br><strong>mRID:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().getMRID() + "<br><strong>Name:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getName() + "<br><strong>NameType Name:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getName() + "<br><strong>NameType Description:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getDescription() + "<br><strong>NameTypeAuthority Name:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getName() + "<br><strong>NameTypeAuthority Description:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getDescription();
return confirmation;
} catch (FaultMessage ex) {
error = ex.getMessage();
return error;
} catch (IndexOutOfBoundsException err) {
return "<p style=\"color:red\"><strong>No deletion made.<br>Provided UUID does not currently exist in the database</strong>.<br>Please double check input UUID.<br>";
}
} else /* modification handling */
if (action.equals("modify")) {
HeaderType header = new HeaderType();
header.setNoun("CIMIdentities");
header.setVerb("change");
msg.setHeader(header);
/* query the server for the mRID being modified */
CIMIdentitiesQueriesRequestType request = new CIMIdentitiesQueriesRequestType();
CIMIdentitiesQueries var = new CIMIdentitiesQueries();
EndDeviceGroup edg = new EndDeviceGroup();
// can be null, '?', or '""' to receive all data, else set mRID
edg.setMRID(mRID);
message.setRequest(request);
message.getRequest().setCIMIdentitiesQueries(var);
message.getRequest().getCIMIdentitiesQueries().getEndDeviceGroup().add(0, edg);
message.getRequest().getCIMIdentitiesQueries().getEndDeviceGroup();
try {
response = queryCIMIdentities(message);
} catch (QueryCIMIdentitiesFaultMessage ex) {
return response.getReply().getError().get(0).getDetails();
}
try {
if (response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().getMRID() == null)
throw new IndexOutOfBoundsException("mRID doesn't exist");
changedCIMIdentitiesRequest(msg);
String confirmation = "Data modified:<br>" + "<strong>Previous data:</strong><br>" + "<br><strong>mRID:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().getMRID() + "<br><strong>Name:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getName() + "<br><strong>NameType Name:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getName() + "<br><strong>NameType Description:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getDescription() + "<br><strong>NameTypeAuthority Name:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getName() + "<br><strong>NameTypeAuthority Description:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getDescription() + "<br><br><br><strong>New data:</strong><br>" + "<br><strong>Name:</strong> " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getName() + "<br><strong>NameType Name:</strong> " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getName() + "<br><strong>NameType Description:</strong> " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getDescription() + "<br><strong>NameTypeAuthority Name:</strong> " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getName() + "<br><strong>NameTypeAuthority Description:</strong> " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getDescription();
return confirmation;
} catch (FaultMessage ex) {
error = ex.getMessage();
return error;
} catch (IndexOutOfBoundsException err) {
return "<p style=\"color:red\"><strong>Provided UUID does not currently exist in the database</strong>.<br>Please double check input UUID.<br>";
}
} else
return "Error: Invalid response received.\n";
}
Aggregations