Search in sources :

Example 11 with Location

use of org.hl7.fhir.dstu3.model.Location in project gpconnect-demonstrator by nhsconnect.

the class OrganizationResourceProvider method getValidAddress.

private Address getValidAddress(Organization organization) {
    List<LocationDetails> locationsDetails = locationSearch.findAllLocations();
    LocationDetails location = null;
    for (LocationDetails locationDetails : locationsDetails) {
        if (locationDetails.getOrgOdsCode().equals(organization.getIdentifierFirstRep().getValue())) {
            location = locationDetails;
            break;
        }
    }
    Address orgAddress = null;
    if (location != null) {
        orgAddress = new Address();
        orgAddress.setUse(AddressUse.WORK);
        // #152
        // this looks very odd but is deliberate, there's a similar issue in locationResourceProvider.createAddress
        // They result from a change to spec to remove the state attribute from the address
        // See the commit cd26528 by James Cox 6/3/18
        orgAddress.addLine(location.getAddressLine());
        orgAddress.addLine(location.getAddressCity());
        orgAddress.setCity(location.getAddressDistrict());
        orgAddress.setDistrict(location.getAddressState());
        orgAddress.setPostalCode(location.getAddressPostalCode());
    }
    return orgAddress;
}
Also used : Address(org.hl7.fhir.dstu3.model.Address) LocationDetails(uk.gov.hscic.model.location.LocationDetails)

Example 12 with Location

use of org.hl7.fhir.dstu3.model.Location in project metacat by Netflix.

the class S3ConnectorTableService method update.

@Override
public void update(@Nonnull final ConnectorContext context, @Nonnull final TableInfo tableInfo) {
    log.debug("Start: Update table {}", tableInfo.getName());
    final QualifiedName tableName = tableInfo.getName();
    final Table table = tableDao.getBySourceDatabaseTableName(catalogName, tableName.getDatabaseName(), tableName.getTableName());
    if (table == null) {
        throw new TableNotFoundException(tableName);
    }
    //we can update the fields, the uri, or the full serde
    final Location newLocation = infoConverter.toLocation(tableInfo);
    Location location = table.getLocation();
    if (location == null) {
        location = new Location();
        location.setTable(table);
        table.setLocation(location);
    }
    if (newLocation.getUri() != null) {
        location.setUri(newLocation.getUri());
    }
    final Info newInfo = newLocation.getInfo();
    if (newInfo != null) {
        final Info info = location.getInfo();
        if (info == null) {
            location.setInfo(newInfo);
            newInfo.setLocation(location);
        } else {
            if (newInfo.getInputFormat() != null) {
                info.setInputFormat(newInfo.getInputFormat());
            }
            if (newInfo.getOutputFormat() != null) {
                info.setOutputFormat(newInfo.getOutputFormat());
            }
            if (newInfo.getOwner() != null) {
                info.setOwner(newInfo.getOwner());
            }
            if (newInfo.getSerializationLib() != null) {
                info.setSerializationLib(newInfo.getSerializationLib());
            }
            if (newInfo.getParameters() != null && !newInfo.getParameters().isEmpty()) {
                info.setParameters(newInfo.getParameters());
            }
        }
    }
    final Schema newSchema = newLocation.getSchema();
    if (newSchema != null) {
        final List<Field> newFields = newSchema.getFields();
        if (newFields != null && !newFields.isEmpty()) {
            final Schema schema = location.getSchema();
            if (schema == null) {
                location.setSchema(newSchema);
                newSchema.setLocation(location);
            } else {
                final List<Field> fields = schema.getFields();
                if (fields.isEmpty()) {
                    newFields.forEach(field -> {
                        field.setSchema(schema);
                        fields.add(field);
                    });
                } else {
                    for (int i = 0; i < newFields.size(); i++) {
                        final Field newField = newFields.get(i);
                        newField.setPos(i);
                        newField.setSchema(schema);
                        if (newField.getType() == null) {
                            newField.setType(newField.getSourceType());
                        }
                    }
                    schema.setFields(null);
                    fieldDao.delete(fields);
                    tableDao.save(table, true);
                    schema.setFields(newFields);
                }
            }
        }
    }
    log.debug("End: Update table {}", tableInfo.getName());
}
Also used : TableNotFoundException(com.netflix.metacat.common.server.connectors.exception.TableNotFoundException) Field(com.netflix.metacat.connector.s3.model.Field) Table(com.netflix.metacat.connector.s3.model.Table) QualifiedName(com.netflix.metacat.common.QualifiedName) Schema(com.netflix.metacat.connector.s3.model.Schema) Info(com.netflix.metacat.connector.s3.model.Info) TableInfo(com.netflix.metacat.common.server.connectors.model.TableInfo) Location(com.netflix.metacat.connector.s3.model.Location)

Example 13 with Location

use of org.hl7.fhir.dstu3.model.Location in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineApplicationCreateDialog method refreshLocationsSelector.

/**
 * Refreshes the locations combo box. This method should be called from the event dispatch thread.
 */
@SuppressWarnings("FutureReturnValueIgnored")
private void refreshLocationsSelector() {
    // show loading state
    disable();
    regionComboBox.removeAllItems();
    ApplicationManager.getApplication().executeOnPooledThread(() -> {
        final List<Location> appEngineRegions;
        try {
            appEngineRegions = AppEngineAdminService.getInstance().getAllAppEngineLocations(userCredential);
        } catch (IOException | GoogleApiException e) {
            setStatusMessageAsync(GctBundle.message("appengine.application.region.list.fetch.error"));
            enable();
            return;
        }
        // perform the actual UI updates on the event dispatch thread
        ApplicationManager.getApplication().invokeLater(() -> {
            for (Location location : appEngineRegions) {
                regionComboBox.addItem(new AppEngineLocationSelectorItem(location));
            }
            enable();
        }, ModalityState.stateForComponent(AppEngineApplicationCreateDialog.this.getContentPane()));
    });
}
Also used : IOException(java.io.IOException) Location(com.google.api.services.appengine.v1.model.Location)

Example 14 with Location

use of org.hl7.fhir.dstu3.model.Location in project google-cloud-intellij by GoogleCloudPlatform.

the class GoogleApiClientAppEngineAdminServiceTest method testGetAllAppEngineLocations_success.

@Test
public void testGetAllAppEngineLocations_success() throws IOException, GoogleApiException {
    String pageToken = "page-token";
    ListLocationsResponse response1 = new ListLocationsResponse();
    List<Location> locationsPage1 = Arrays.asList(createMockLocation("location-1"), createMockLocation("location-2"));
    response1.setLocations(locationsPage1);
    response1.setNextPageToken(pageToken);
    List<Location> locationsPage2 = Arrays.asList(createMockLocation("location-3"), createMockLocation("location-4"));
    ListLocationsResponse response2 = new ListLocationsResponse();
    response2.setLocations(locationsPage2);
    response2.setNextPageToken(null);
    when(appengineClientMock.getAppsLocationsListQuery().setPageToken(any())).thenReturn(appengineClientMock.getAppsLocationsListQuery());
    when(appengineClientMock.getAppsLocationsListQuery().execute()).thenReturn(response1);
    Appengine.Apps.Locations.List appsLocationsListQuery2 = mock(Appengine.Apps.Locations.List.class);
    when(appengineClientMock.getAppsLocationsListQuery().setPageToken(eq(pageToken))).thenReturn(appsLocationsListQuery2);
    when(appsLocationsListQuery2.execute()).thenReturn(response2);
    List<Location> expectedResults = new ArrayList<>(locationsPage1);
    expectedResults.addAll(locationsPage2);
    // make the call twice. the service should only be hit once per page
    assertEquals(expectedResults, service.getAllAppEngineLocations(mock(Credential.class)));
    assertEquals(expectedResults, service.getAllAppEngineLocations(mock(Credential.class)));
    verify(appengineClientMock.getAppsLocationsListQuery(), times(1)).execute();
    verify(appsLocationsListQuery2, times(1)).execute();
}
Also used : ListLocationsResponse(com.google.api.services.appengine.v1.model.ListLocationsResponse) Appengine(com.google.api.services.appengine.v1.Appengine) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Location(com.google.api.services.appengine.v1.model.Location) Test(org.junit.Test)

Example 15 with Location

use of org.hl7.fhir.dstu3.model.Location in project google-cloud-intellij by GoogleCloudPlatform.

the class GoogleApiClientAppEngineAdminServiceTest method createMockLocation.

private Location createMockLocation(String id) {
    Location location = new Location();
    location.setLocationId(id);
    return location;
}
Also used : Location(com.google.api.services.appengine.v1.model.Location)

Aggregations

Location (com.netflix.metacat.connector.s3.model.Location)9 Location (com.google.api.services.appengine.v1.model.Location)6 TableInfo (com.netflix.metacat.common.server.connectors.model.TableInfo)6 Info (com.netflix.metacat.connector.s3.model.Info)6 FieldInfo (com.netflix.metacat.common.server.connectors.model.FieldInfo)5 AuditInfo (com.netflix.metacat.common.server.connectors.model.AuditInfo)4 DatabaseInfo (com.netflix.metacat.common.server.connectors.model.DatabaseInfo)4 PartitionInfo (com.netflix.metacat.common.server.connectors.model.PartitionInfo)4 StorageInfo (com.netflix.metacat.common.server.connectors.model.StorageInfo)4 Schema (com.netflix.metacat.connector.s3.model.Schema)4 Reference (org.hl7.fhir.dstu3.model.Reference)4 Field (com.netflix.metacat.connector.s3.model.Field)3 Table (com.netflix.metacat.connector.s3.model.Table)3 IdType (org.hl7.fhir.dstu3.model.IdType)3 Location (org.hl7.fhir.dstu3.model.Location)3 SlotDetail (uk.gov.hscic.model.appointment.SlotDetail)3 LocationDetails (uk.gov.hscic.model.location.LocationDetails)3 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)2 ListLocationsResponse (com.google.api.services.appengine.v1.model.ListLocationsResponse)2 QualifiedName (com.netflix.metacat.common.QualifiedName)2