use of org.geotoolkit.sml.xml.v100.Keywords in project ORCID-Source by ORCID.
the class KeywordsTest method testCreateGetUpdateAndDeleteKeyword_rc3.
/**
* --------- -- -- -- RC3 -- -- -- ---------
*/
@SuppressWarnings({ "deprecation", "rawtypes" })
@Test
public void testCreateGetUpdateAndDeleteKeyword_rc3() throws InterruptedException, JSONException {
changeDefaultUserVisibility(org.orcid.jaxb.model.common_v2.Visibility.LIMITED);
changeCurrentKeywordsVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
String accessToken = getAccessToken();
assertNotNull(accessToken);
org.orcid.jaxb.model.record_rc3.Keyword newKeyword = new org.orcid.jaxb.model.record_rc3.Keyword();
newKeyword.setContent("keyword-3");
newKeyword.setVisibility(org.orcid.jaxb.model.common_rc3.Visibility.PUBLIC);
// Create
ClientResponse response = memberV2ApiClient_rc3.createKeyword(getUser1OrcidId(), newKeyword, accessToken);
assertNotNull(response);
assertEquals(ClientResponse.Status.CREATED.getStatusCode(), response.getStatus());
Map map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List resultWithPutCode = (List) map.get("Location");
String location = resultWithPutCode.get(0).toString();
Long putCode = Long.valueOf(location.substring(location.lastIndexOf('/') + 1));
// Get all and verify
response = memberV2ApiClient_rc3.viewKeywords(getUser1OrcidId(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
Keywords keywords = response.getEntity(Keywords.class);
assertNotNull(keywords);
assertNotNull(keywords.getKeywords());
boolean found1 = false;
boolean found2 = false;
boolean foundNew = false;
for (org.orcid.jaxb.model.record_rc3.Keyword existingKeyword : keywords.getKeywords()) {
if (existingKeyword.getContent().equals(keyword1)) {
assertEquals(org.orcid.jaxb.model.common_rc3.Visibility.PUBLIC, existingKeyword.getVisibility());
found1 = true;
} else if (existingKeyword.getContent().equals(keyword2)) {
assertEquals(org.orcid.jaxb.model.common_rc3.Visibility.PUBLIC, existingKeyword.getVisibility());
found2 = true;
} else if (existingKeyword.getContent().equals(newKeyword.getContent())) {
assertEquals(org.orcid.jaxb.model.common_rc3.Visibility.LIMITED, existingKeyword.getVisibility());
assertEquals("keyword-3", existingKeyword.getContent());
assertEquals(getClient1ClientId(), existingKeyword.getSource().retrieveSourcePath());
foundNew = true;
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(foundNew);
// Get it
response = memberV2ApiClient_rc3.viewKeyword(getUser1OrcidId(), putCode, accessToken);
assertNotNull(response);
newKeyword = response.getEntity(Keyword.class);
assertNotNull(newKeyword);
assertNotNull(newKeyword.getSource());
assertEquals(getClient1ClientId(), newKeyword.getSource().retrieveSourcePath());
assertEquals("keyword-3", newKeyword.getContent());
assertEquals(org.orcid.jaxb.model.common_rc3.Visibility.LIMITED, newKeyword.getVisibility());
assertNotNull(newKeyword.getDisplayIndex());
Long originalDisplayIndex = newKeyword.getDisplayIndex();
// Save the original visibility
org.orcid.jaxb.model.common_rc3.Visibility originalVisibility = newKeyword.getVisibility();
org.orcid.jaxb.model.common_rc3.Visibility updatedVisibility = org.orcid.jaxb.model.common_rc3.Visibility.PRIVATE;
// Verify you cant update the visibility
newKeyword.setVisibility(updatedVisibility);
ClientResponse putResponse = memberV2ApiClient_rc3.updateKeyword(getUser1OrcidId(), newKeyword, accessToken);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
org.orcid.jaxb.model.error_rc3.OrcidError error = putResponse.getEntity(org.orcid.jaxb.model.error_rc3.OrcidError.class);
assertNotNull(error);
assertEquals(Integer.valueOf(9035), error.getErrorCode());
// Set the visibility again to the initial one
newKeyword.setVisibility(originalVisibility);
// Update
newKeyword.setContent("keyword-3-updated");
response = memberV2ApiClient_rc3.updateKeyword(getUser1OrcidId(), newKeyword, accessToken);
assertNotNull(response);
assertEquals(ClientResponse.Status.OK.getStatusCode(), response.getStatus());
response = memberV2ApiClient_rc3.viewKeyword(getUser1OrcidId(), putCode, accessToken);
assertNotNull(response);
org.orcid.jaxb.model.record_rc3.Keyword updatedKeyword = response.getEntity(Keyword.class);
assertNotNull(updatedKeyword);
assertEquals("keyword-3-updated", updatedKeyword.getContent());
assertEquals(newKeyword.getPutCode(), updatedKeyword.getPutCode());
assertEquals(originalDisplayIndex, updatedKeyword.getDisplayIndex());
// Delete
response = memberV2ApiClient_rc3.deleteKeyword(getUser1OrcidId(), putCode, accessToken);
assertNotNull(response);
assertEquals(ClientResponse.Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
use of org.geotoolkit.sml.xml.v100.Keywords 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.geotoolkit.sml.xml.v100.Keywords 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.geotoolkit.sml.xml.v100.Keywords in project geotoolkit by Geomatys.
the class SmlXMLFactory method convertTo101.
public static org.geotoolkit.sml.xml.v101.SensorML convertTo101(final org.geotoolkit.sml.xml.v100.SensorML sensor) {
List<org.geotoolkit.sml.xml.v101.SensorML.Member> newMembers = new ArrayList<org.geotoolkit.sml.xml.v101.SensorML.Member>();
for (Member oldMember : sensor.getMember()) {
final org.geotoolkit.sml.xml.v101.AbstractProcessType newProcess;
if (oldMember.getRealProcess() instanceof System) {
newProcess = new org.geotoolkit.sml.xml.v101.SystemType();
} else if (oldMember.getRealProcess() instanceof Component) {
newProcess = new org.geotoolkit.sml.xml.v101.ComponentType();
} else if (oldMember.getRealProcess() instanceof AbstractDataSource) {
newProcess = new org.geotoolkit.sml.xml.v101.DataSourceType();
} else if (oldMember.getRealProcess() instanceof AbstractProcessModel) {
newProcess = new org.geotoolkit.sml.xml.v101.ProcessModelType();
} else if (oldMember.getRealProcess() instanceof ComponentArray) {
newProcess = new org.geotoolkit.sml.xml.v101.ComponentArrayType();
} else {
throw new IllegalArgumentException("Other sensor type than system, component, processModel, processChain, componentArray or datasource are not yet convertible");
}
AbstractProcessType oldProcess = (AbstractProcessType) oldMember.getRealProcess();
// id
newProcess.setId(oldProcess.getId());
// name
newProcess.setName(oldProcess.getName());
// srsName
newProcess.setSrsName(oldProcess.getSrsName());
// description
newProcess.setDescription(oldProcess.getDescription());
// boundedBy
newProcess.setBoundedBy(oldProcess.getBoundedBy());
// capabilities
List<org.geotoolkit.sml.xml.v101.Capabilities> newCapabilities = new ArrayList<org.geotoolkit.sml.xml.v101.Capabilities>();
for (Capabilities oldCapa : oldProcess.getCapabilities()) {
newCapabilities.add(new org.geotoolkit.sml.xml.v101.Capabilities(oldCapa));
}
newProcess.setCapabilities(newCapabilities);
// characteristics
List<org.geotoolkit.sml.xml.v101.Characteristics> newCharacteristics = new ArrayList<org.geotoolkit.sml.xml.v101.Characteristics>();
for (Characteristics oldChar : oldProcess.getCharacteristics()) {
newCharacteristics.add(new org.geotoolkit.sml.xml.v101.Characteristics(oldChar));
}
newProcess.setCharacteristics(newCharacteristics);
// Classification
List<org.geotoolkit.sml.xml.v101.Classification> newClassification = new ArrayList<org.geotoolkit.sml.xml.v101.Classification>();
for (Classification oldClass : oldProcess.getClassification()) {
newClassification.add(new org.geotoolkit.sml.xml.v101.Classification(oldClass));
}
newProcess.setClassification(newClassification);
// Contact
List<org.geotoolkit.sml.xml.v101.Contact> newContact = new ArrayList<org.geotoolkit.sml.xml.v101.Contact>();
for (Contact oldContact : oldProcess.getContact()) {
newContact.add(new org.geotoolkit.sml.xml.v101.Contact(oldContact));
}
newProcess.setContact(newContact);
// Contact
List<org.geotoolkit.sml.xml.v101.Documentation> newDocumentation = new ArrayList<org.geotoolkit.sml.xml.v101.Documentation>();
for (Documentation oldDoc : oldProcess.getDocumentation()) {
newDocumentation.add(new org.geotoolkit.sml.xml.v101.Documentation(oldDoc));
}
newProcess.setDocumentation(newDocumentation);
// History
List<org.geotoolkit.sml.xml.v101.History> newHistory = new ArrayList<org.geotoolkit.sml.xml.v101.History>();
for (History oldhist : oldProcess.getHistory()) {
newHistory.add(new org.geotoolkit.sml.xml.v101.History(oldhist));
}
newProcess.setHistory(newHistory);
// Identification
List<org.geotoolkit.sml.xml.v101.Identification> newIdentification = new ArrayList<org.geotoolkit.sml.xml.v101.Identification>();
for (Identification oldIdent : oldProcess.getIdentification()) {
newIdentification.add(new org.geotoolkit.sml.xml.v101.Identification(oldIdent));
}
newProcess.setIdentification(newIdentification);
// keywords
List<org.geotoolkit.sml.xml.v101.Keywords> newKeywords = new ArrayList<org.geotoolkit.sml.xml.v101.Keywords>();
for (Keywords oldKeyw : oldProcess.getKeywords()) {
newKeywords.add(new org.geotoolkit.sml.xml.v101.Keywords(oldKeyw));
}
newProcess.setKeywords(newKeywords);
// legal constraint
List<org.geotoolkit.sml.xml.v101.LegalConstraint> newLegalConstraints = new ArrayList<org.geotoolkit.sml.xml.v101.LegalConstraint>();
for (LegalConstraint oldcons : oldProcess.getLegalConstraint()) {
newLegalConstraints.add(new org.geotoolkit.sml.xml.v101.LegalConstraint(oldcons));
}
newProcess.setLegalConstraint(newLegalConstraints);
// security constraint
if (oldProcess.getSecurityConstraint() != null) {
newProcess.setSecurityConstraint(new org.geotoolkit.sml.xml.v101.SecurityConstraint(oldProcess.getSecurityConstraint()));
}
// validTime
if (oldProcess.getValidTime() != null) {
newProcess.setValidTime(oldProcess.getValidTime());
}
if (oldProcess instanceof AbstractComponent) {
AbstractComponent newAbsComponent = (AbstractComponent) newProcess;
AbstractComponent oldAbsComponent = (AbstractComponent) oldProcess;
// Inputs
if (oldAbsComponent.getInputs() != null) {
newAbsComponent.setInputs(oldAbsComponent.getInputs());
}
// outputs
if (oldAbsComponent.getOutputs() != null) {
newAbsComponent.setOutputs(oldAbsComponent.getOutputs());
}
// parameters
if (oldAbsComponent.getParameters() != null) {
newAbsComponent.setParameters(oldAbsComponent.getParameters());
}
}
if (oldProcess instanceof AbstractDerivableComponent) {
org.geotoolkit.sml.xml.v101.AbstractDerivableComponentType newDerComponent = (org.geotoolkit.sml.xml.v101.AbstractDerivableComponentType) newProcess;
AbstractDerivableComponent oldDerComponent = (AbstractDerivableComponent) oldProcess;
// Position
if (oldDerComponent.getPosition() != null) {
newDerComponent.setPosition(oldDerComponent.getPosition());
}
if (oldDerComponent.getSMLLocation() != null) {
newDerComponent.setSMLLocation(oldDerComponent.getSMLLocation());
}
if (oldDerComponent.getInterfaces() != null) {
newDerComponent.setInterfaces(new org.geotoolkit.sml.xml.v101.Interfaces(oldDerComponent.getInterfaces()));
}
if (oldDerComponent.getSpatialReferenceFrame() != null) {
newDerComponent.setSpatialReferenceFrame(new org.geotoolkit.sml.xml.v101.SpatialReferenceFrame(oldDerComponent.getSpatialReferenceFrame()));
}
if (oldDerComponent.getTemporalReferenceFrame() != null) {
newDerComponent.setTemporalReferenceFrame(new org.geotoolkit.sml.xml.v101.TemporalReferenceFrame(oldDerComponent.getTemporalReferenceFrame()));
}
if (oldDerComponent.getTimePosition() != null) {
newDerComponent.setTimePosition(new org.geotoolkit.sml.xml.v101.TimePosition(oldDerComponent.getTimePosition()));
}
}
if (oldProcess instanceof AbstractPureProcess) {
org.geotoolkit.sml.xml.v101.AbstractPureProcessType newAbsPuProc = (org.geotoolkit.sml.xml.v101.AbstractPureProcessType) newProcess;
AbstractPureProcess oldAbsPuProc = (AbstractPureProcess) oldProcess;
// Inputs
if (oldAbsPuProc.getInputs() != null) {
newAbsPuProc.setInputs(new org.geotoolkit.sml.xml.v101.Inputs(oldAbsPuProc.getInputs()));
}
// outputs
if (oldAbsPuProc.getOutputs() != null) {
newAbsPuProc.setOutputs(new org.geotoolkit.sml.xml.v101.Outputs(oldAbsPuProc.getOutputs()));
}
// parameters
if (oldAbsPuProc.getParameters() != null) {
newAbsPuProc.setParameters(new org.geotoolkit.sml.xml.v101.Parameters(oldAbsPuProc.getParameters()));
}
}
if (oldMember.getRealProcess() instanceof System) {
SystemType oldSystem = (SystemType) oldMember.getRealProcess();
org.geotoolkit.sml.xml.v101.SystemType newSystem = (org.geotoolkit.sml.xml.v101.SystemType) newProcess;
// components
if (oldSystem.getComponents() != null) {
newSystem.setComponents(new org.geotoolkit.sml.xml.v101.Components(oldSystem.getComponents()));
}
// positions
if (oldSystem.getPositions() != null) {
newSystem.setPositions(new org.geotoolkit.sml.xml.v101.Positions(oldSystem.getPositions()));
}
// connections
if (oldSystem.getConnections() != null) {
newSystem.setConnections(new org.geotoolkit.sml.xml.v101.Connections(oldSystem.getConnections()));
}
} else if (oldMember.getRealProcess() instanceof Component) {
ComponentType oldComponent = (ComponentType) oldMember.getRealProcess();
org.geotoolkit.sml.xml.v101.ComponentType newCompo = (org.geotoolkit.sml.xml.v101.ComponentType) newProcess;
// method
if (oldComponent.getMethod() != null) {
newCompo.setMethod(new org.geotoolkit.sml.xml.v101.MethodPropertyType(oldComponent.getMethod()));
}
} else if (oldMember.getRealProcess() instanceof AbstractDataSource) {
DataSourceType oldDataSource = (DataSourceType) oldMember.getRealProcess();
org.geotoolkit.sml.xml.v101.DataSourceType newDataSource = (org.geotoolkit.sml.xml.v101.DataSourceType) newProcess;
if (oldDataSource.getDataDefinition() != null) {
newDataSource.setDataDefinition(new org.geotoolkit.sml.xml.v101.DataDefinition(oldDataSource.getDataDefinition()));
}
if (oldDataSource.getValues() != null) {
newDataSource.setValues(new org.geotoolkit.sml.xml.v101.Values(oldDataSource.getValues()));
}
if (oldDataSource.getObservationReference() != null) {
newDataSource.setObservationReference(new org.geotoolkit.sml.xml.v101.ObservationReference(oldDataSource.getObservationReference()));
}
} else if (oldMember.getRealProcess() instanceof AbstractProcessModel) {
ProcessModelType oldProcessModel = (ProcessModelType) oldMember.getRealProcess();
org.geotoolkit.sml.xml.v101.ProcessModelType newProcessModel = (org.geotoolkit.sml.xml.v101.ProcessModelType) newProcess;
if (oldProcessModel.getMethod() != null) {
newProcessModel.setMethod(new org.geotoolkit.sml.xml.v101.MethodPropertyType(oldProcessModel.getMethod()));
}
} else if (oldMember.getRealProcess() instanceof AbstractProcessChain) {
ProcessChainType oldProcessChain = (ProcessChainType) oldMember.getRealProcess();
org.geotoolkit.sml.xml.v101.ProcessChainType newProcessChain = (org.geotoolkit.sml.xml.v101.ProcessChainType) newProcess;
// components
if (oldProcessChain.getComponents() != null) {
newProcessChain.setComponents(new org.geotoolkit.sml.xml.v101.Components(oldProcessChain.getComponents()));
}
// connections
if (oldProcessChain.getConnections() != null) {
newProcessChain.setConnections(new org.geotoolkit.sml.xml.v101.Connections(oldProcessChain.getConnections()));
}
} else if (oldMember.getRealProcess() instanceof ComponentArray) {
// nothing to do
} else {
throw new IllegalArgumentException("Other sensor type than system ,component, processModel, processChain, componentArray or datasource are not yet convertible");
}
newMembers.add(new org.geotoolkit.sml.xml.v101.SensorML.Member(newProcess));
}
org.geotoolkit.sml.xml.v101.SensorML result = new org.geotoolkit.sml.xml.v101.SensorML("1.0.1", newMembers);
return result;
}
use of org.geotoolkit.sml.xml.v100.Keywords in project geotoolkit by Geomatys.
the class SmlXMLBindingTest method SystemMarshalingTest.
/**
* Test simple Record Marshalling.
*
* @throws java.lang.Exception
*/
@Test
public void SystemMarshalingTest() throws Exception {
SensorML.Member member = new SensorML.Member();
SystemType system = new SystemType();
system.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-09-CTD-1");
List<String> kw = new ArrayList<String>();
kw.add("OCEANS");
kw.add("OCEANS:OCEAN TEMPERATURE");
kw.add("OCEANS:OCEAN PRESSURE");
kw.add("OCEANS:SALINITY/DENSITY");
kw.add("Instruments/Sensors:In Situ/Laboratory Instruments:Conductivity Sensors");
Keywords keywords = new Keywords(new KeywordList(URI.create("urn:x-nasa:def:gcmd:keywords"), kw));
system.setKeywords(keywords);
CodeSpacePropertyType cs = new CodeSpacePropertyType("urn:x-ogc:dictionary::sensorTypes");
Classifier cl2 = new Classifier("sensorType", new Term(cs, "CTD", "urn:x-ogc:def:classifier:OGC:sensorType"));
List<Classifier> cls = new ArrayList<Classifier>();
cls.add(cl2);
ClassifierList claList = new ClassifierList(null, cls);
Classification classification = new Classification(claList);
system.setClassification(classification);
List<Identifier> identifiers = new ArrayList<Identifier>();
Identifier id1 = new Identifier("uniqueID", new Term("urn:ogc:object:feature:Sensor:IFREMER:13471-09-CTD-1", "urn:ogc:def:identifierType:OGC:uniqueID"));
Identifier id2 = new Identifier("shortName", new Term("Microcat_CT_SBE37", "urn:x-ogc:def:identifier:OGC:shortName"));
cs = new CodeSpacePropertyType("urn:x-ogc:def:identifier:SBE:modelNumber");
Identifier id3 = new Identifier("modelNumber", new Term(cs, "", "urn:x-ogc:def:identifier:OGC:modelNumber"));
cs = new CodeSpacePropertyType("urn:x-ogc:def:identifier:SBE:serialNumber");
Identifier id4 = new Identifier("serialNumber", new Term(cs, "", "urn:x-ogc:def:identifier:OGC:serialNumber"));
identifiers.add(id1);
identifiers.add(id2);
identifiers.add(id3);
identifiers.add(id4);
IdentifierList identifierList = new IdentifierList(null, identifiers);
Identification identification = new Identification(identifierList);
system.setIdentification(identification);
Address address1 = new Address("1808 136th Place NE", "Bellevue", "Washington", "98005", "USA", null);
Phone phone1 = new Phone("+1 (425) 643-9866", "+1 (425) 643-9954");
ContactInfo contactInfo1 = new ContactInfo(phone1, address1);
contactInfo1.setOnlineResource(new OnlineResource("http://www.seabird.com"));
ResponsibleParty resp1 = new ResponsibleParty(null, "Sea-Bird Electronics, Inc.", null, contactInfo1);
Contact contact1 = new Contact(null, resp1);
contact1.setArcrole("urn:x-ogc:def:classifiers:OGC:contactType:manufacturer");
system.setContact(Arrays.asList(contact1));
List<ComponentPropertyType> compos = new ArrayList<ComponentPropertyType>();
ComponentType compo1 = new ComponentType();
compo1.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-1017-PSAL-2.0");
List<IoComponentPropertyType> ios1 = new ArrayList<IoComponentPropertyType>();
ios1.add(new IoComponentPropertyType("CNDC", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:CNDC")));
ios1.add(new IoComponentPropertyType("TEMP", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:TEMP")));
ios1.add(new IoComponentPropertyType("PRES", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:PRES")));
Inputs inputs1 = new Inputs(ios1);
compo1.setInputs(inputs1);
QuantityType q = new QuantityType("urn:x-ogc:def:phenomenon:OGC:PSAL", new UomPropertyType("P.S.U", null), null);
q.setParameterName(new CodeType("#sea_water_electrical_conductivity", "http://cf-pcmdi.llnl.gov/documents/cf-standard-names/standard-name-table/11/standard-name-table"));
IoComponentPropertyType io1 = new IoComponentPropertyType("computedPSAL", q);
Outputs outputs1 = new Outputs(Arrays.asList(io1));
compo1.setOutputs(outputs1);
compos.add(new ComponentPropertyType("IFREMER-13471-1017-PSAL-2.0", sml101Factory.createComponent(compo1)));
ComponentType compo2 = new ComponentType();
compo2.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-1017-CNDC-2.0");
List<IoComponentPropertyType> ios2 = new ArrayList<IoComponentPropertyType>();
ios2.add(new IoComponentPropertyType("CNDC", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:CNDC")));
Inputs inputs2 = new Inputs(ios2);
compo2.setInputs(inputs2);
QuantityType q2 = new QuantityType("urn:x-ogc:def:phenomenon:OGC:CNDC", new UomPropertyType("mhos/m", null), null);
q2.setParameterName(new CodeType("#sea_water_electrical_conductivity", "http://cf-pcmdi.llnl.gov/documents/cf-standard-names/standard-name-table/11/standard-name-table"));
IoComponentPropertyType io2 = new IoComponentPropertyType("measuredCNDC", q2);
Outputs outputs2 = new Outputs(Arrays.asList(io2));
compo2.setOutputs(outputs2);
compos.add(new ComponentPropertyType("IFREMER-13471-1017-CNDC-2.0", sml101Factory.createComponent(compo2)));
ComponentType compo3 = new ComponentType();
compo3.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-1017-PRES-2.0");
compo3.setDescription("Conductivity detector connected to the SBE37SMP Recorder");
List<IoComponentPropertyType> ios3 = new ArrayList<IoComponentPropertyType>();
ios3.add(new IoComponentPropertyType("PRES", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:PRES")));
Inputs inputs3 = new Inputs(ios3);
compo3.setInputs(inputs3);
UomPropertyType uom3 = new UomPropertyType("dBar", null);
uom3.setTitle("decibar=10000 pascals");
QuantityType q3 = new QuantityType("urn:x-ogc:def:phenomenon:OGC:PRES", uom3, null);
q3.setParameterName(new CodeType("#sea_water_pressure", "http://cf-pcmdi.llnl.gov/documents/cf-standard-names/standard-name-table/11/standard-name-table"));
IoComponentPropertyType io3 = new IoComponentPropertyType("measuredPRES", q3);
Outputs outputs3 = new Outputs(Arrays.asList(io3));
compo3.setOutputs(outputs3);
compos.add(new ComponentPropertyType("IFREMER-13471-1017-PRES-2.0", sml101Factory.createComponent(compo3)));
ComponentType compo4 = new ComponentType();
compo4.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-1017-TEMP-2.0");
compo4.setDescription(" Temperature detector connected to the SBE37SMP Recorder");
List<IoComponentPropertyType> ios4 = new ArrayList<IoComponentPropertyType>();
ios4.add(new IoComponentPropertyType("TEMP", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:TEMP")));
Inputs inputs4 = new Inputs(ios4);
compo4.setInputs(inputs4);
UomPropertyType uom4 = new UomPropertyType("Cel", null);
uom4.setTitle("Celsius degree");
QuantityType q4 = new QuantityType("urn:x-ogc:def:phenomenon:OGC:TEMP", uom4, null);
q4.setParameterName(new CodeType("#sea_water_temperature", "http://cf-pcmdi.llnl.gov/documents/cf-standard-names/standard-name-table/11/standard-name-table"));
IoComponentPropertyType io4 = new IoComponentPropertyType("measuredTEMP", q4);
Outputs outputs4 = new Outputs(Arrays.asList(io4));
compo4.setOutputs(outputs4);
List<DataComponentPropertyType> params4 = new ArrayList<DataComponentPropertyType>();
List<DataComponentPropertyType> fields4 = new ArrayList<DataComponentPropertyType>();
QuantityRange qr = new QuantityRange(new UomPropertyType("Cel", null), Arrays.asList(-5.0, 35.0));
qr.setDefinition("urn:x-ogc:def:sensor:dynamicRange");
fields4.add(new DataComponentPropertyType("dynamicRange", null, qr));
QuantityType qr2 = new QuantityType("urn:x-ogc:def:sensor:gain", null, 1.0);
fields4.add(new DataComponentPropertyType("gain", null, qr2));
QuantityType qr3 = new QuantityType("urn:x-ogc:def:sensor:offset", null, 0.0);
fields4.add(new DataComponentPropertyType("offset", null, qr3));
DataRecordType record = new DataRecordType("urn:x-ogc:def:sensor:linearCalibration", fields4);
DataComponentPropertyType recordProp = new DataComponentPropertyType(record, "calibration");
recordProp.setRole("urn:x-ogc:def:sensor:steadyState");
params4.add(recordProp);
params4.add(new DataComponentPropertyType("accuracy", "urn:x-ogc:def:sensor:OGC:accuracy", new QuantityType("urn:x-ogc:def:sensor:OGC:absoluteAccuracy", new UomPropertyType("Cel", null), 0.0020)));
ParameterList parameterList4 = new ParameterList(params4);
Parameters parameters4 = new Parameters(parameterList4);
compo4.setParameters(parameters4);
compo4.setMethod(new MethodPropertyType("urn:x-ogc:def:process:1.0:detector"));
compos.add(new ComponentPropertyType("IFREMER-13471-1017-TEMP-2.0", sml101Factory.createComponent(compo4)));
ComponentList componentList = new ComponentList(compos);
Components components = new Components(componentList);
system.setComponents(components);
Interface i1 = new Interface("RS232", null);
List<Interface> interfaceL = new ArrayList<Interface>();
interfaceL.add(i1);
InterfaceList interfaceList = new InterfaceList(null, interfaceL);
Interfaces interfaces = new Interfaces(interfaceList);
system.setInterfaces(interfaces);
system.setDescription("The SBE 37-SMP MicroCAT is a high-accuracy conductivity and temperature (pressure optional) recorder with internal battery and memory, serial communication or Inductive Modem and pump (optional). Designed for moorings or other long duration, fixed-site deployments, the MicroCAT includes a standard serial interface and nonvolatile FLASH memory. Construction is of titanium and other non-corroding materials to ensure long life with minimum maintenance, and depth capability is 7000 meters (23,000 feet).");
member.setProcess(sml101Factory.createSystem(system));
SensorML sensor = new SensorML("1.0.1", Arrays.asList(member));
Marshaller m = SensorMLMarshallerPool.getInstance().acquireMarshaller();
StringWriter sw = new StringWriter();
m.marshal(sensor, sw);
String result = sw.toString();
InputStream in = SmlXMLBindingTest.class.getResourceAsStream("/org/geotoolkit/sml/system101.xml");
StringWriter out = new StringWriter();
byte[] buffer = new byte[1024];
int size;
while ((size = in.read(buffer, 0, 1024)) > 0) {
out.write(new String(buffer, 0, size));
}
String expResult = out.toString();
final DocumentComparator comparator = new DocumentComparator(expResult, result) {
@Override
protected strictfp void compareAttributeNode(Attr expected, Node actual) {
super.compareAttributeNode(expected, actual);
}
};
comparator.ignoredAttributes.add("http://www.w3.org/2000/xmlns:*");
comparator.ignoredAttributes.add("http://www.w3.org/2001/XMLSchema-instance:schemaLocation");
comparator.compare();
SensorMLMarshallerPool.getInstance().recycle(m);
}
Aggregations