Search in sources :

Example 1 with InstanceService

use of eu.esdihumboldt.hale.ui.service.instance.InstanceService in project hale by halestudio.

the class ClearInstancesHandler method execute.

/**
 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    if (MessageDialog.openQuestion(HandlerUtil.getActiveShell(event), "Delete source data", "Do you really want to delete all source data?")) {
        InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
        is.clearInstances();
    }
    return null;
}
Also used : InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService)

Example 2 with InstanceService

use of eu.esdihumboldt.hale.ui.service.instance.InstanceService in project hale by halestudio.

the class HaleServiceFactory method create.

/**
 * @see AbstractServiceFactory#create(Class, IServiceLocator,
 *      IServiceLocator)
 */
@Override
public Object create(@SuppressWarnings("rawtypes") Class serviceInterface, IServiceLocator parentLocator, IServiceLocator locator) {
    if (AlignmentService.class.equals(serviceInterface)) {
        return new AlignmentServiceUndoSupport(new AlignmentServiceImpl(locator.getService(ProjectService.class)));
    }
    if (CompatibilityService.class.equals(serviceInterface)) {
        return new CompatibilityServiceImpl();
    }
    if (EntityDefinitionService.class.equals(serviceInterface)) {
        return new EntityDefinitionServiceUndoSupport(new EntityDefinitionServiceImpl(locator.getService(AlignmentService.class), locator.getService(ProjectService.class)));
    }
    if (EntityResolver.class.equals(serviceInterface)) {
        return new UserFallbackEntityResolver();
    }
    if (FunctionService.class.equals(serviceInterface)) {
        return new HaleFunctionService(locator.getService(AlignmentService.class));
    }
    if (GeometrySchemaService.class.equals(serviceInterface)) {
        return new ProjectGeometrySchemaService(locator.getService(ProjectService.class));
    }
    if (GroovyService.class.equals(serviceInterface)) {
        return new PreferencesGroovyService(locator.getService(ProjectService.class), locator.getService(AlignmentService.class));
    }
    if (InstanceSampleService.class.equals(serviceInterface)) {
        return new InstanceSampleServiceImpl();
    }
    if (InstanceService.class.equals(serviceInterface)) {
        final InstanceService is = OrientInstanceService.getInstance(locator.getService(SchemaService.class), locator.getService(ProjectService.class), locator.getService(AlignmentService.class), locator.getService(GroovyService.class));
        // Add a listener to close all InstanceProcessors when source data
        // is cleared
        // XXX There may a better place to add this listener
        is.addListener(new InstanceServiceAdapter() {

            @Override
            public void datasetChanged(DataSet type) {
                if (type != DataSet.SOURCE) {
                    return;
                }
                InstanceCollection instances = is.getInstances(type);
                if (instances.isEmpty()) {
                    // data was cleared, close instance
                    // processors
                    final InstanceProcessingExtension ext = new InstanceProcessingExtension(HaleUI.getServiceProvider());
                    for (InstanceProcessor processor : ext.getInstanceProcessors()) {
                        try {
                            processor.close();
                        } catch (IOException e) {
                        // Ignore
                        }
                    }
                }
            }
        });
        return is;
    }
    if (InstanceValidationService.class.equals(serviceInterface))
        return new InstanceValidationServiceImpl(locator.getService(InstanceService.class), locator.getService(ReportService.class));
    if (InstanceViewService.class.equals(serviceInterface)) {
        return new InstanceViewServiceImpl(locator.getService(ProjectService.class));
    }
    if (OccurringValuesService.class.equals(serviceInterface)) {
        return new OccurringValuesServiceImpl(locator.getService(InstanceService.class), locator.getService(ProjectService.class));
    }
    if (PopulationService.class.equals(serviceInterface)) {
        return new PopulationServiceImpl(locator.getService(InstanceService.class));
    }
    if (ProjectService.class.equals(serviceInterface)) {
        return new ProjectServiceImpl();
    }
    if (ProjectInfoService.class.equals(serviceInterface)) {
        return locator.getService(ProjectService.class);
    }
    if (RecentProjectsService.class.equals(serviceInterface)) {
        return new RecentProjectsServiceImpl();
    }
    if (RecentResources.class.equals(serviceInterface)) {
        return new RecentResourcesService(locator.getService(ProjectService.class));
    }
    if (ReportService.class.equals(serviceInterface)) {
        return new ReportServiceImpl();
    }
    if (SchemaService.class.equals(serviceInterface)) {
        return new SchemaServiceImpl(locator.getService(ProjectService.class));
    }
    if (TaskService.class.equals(serviceInterface)) {
        return new TaskServiceImpl();
    }
    if (TransformationFunctionService.class.equals(serviceInterface)) {
        return new HaleTransformationFunctionService(locator.getService(AlignmentService.class));
    }
    if (TransformationSchemas.class.equals(serviceInterface)) {
        return locator.getService(SchemaService.class);
    }
    return null;
}
Also used : UserFallbackEntityResolver(eu.esdihumboldt.hale.ui.service.align.resolver.UserFallbackEntityResolver) DataSet(eu.esdihumboldt.hale.common.instance.model.DataSet) TaskServiceImpl(eu.esdihumboldt.hale.ui.service.tasks.internal.TaskServiceImpl) CompatibilityServiceImpl(eu.esdihumboldt.hale.ui.compatibility.extension.impl.CompatibilityServiceImpl) EntityDefinitionServiceUndoSupport(eu.esdihumboldt.hale.ui.service.entity.internal.EntityDefinitionServiceUndoSupport) AlignmentServiceUndoSupport(eu.esdihumboldt.hale.ui.service.align.internal.AlignmentServiceUndoSupport) PreferencesGroovyService(eu.esdihumboldt.hale.ui.service.groovy.internal.PreferencesGroovyService) GroovyService(eu.esdihumboldt.util.groovy.sandbox.GroovyService) ProjectServiceImpl(eu.esdihumboldt.hale.ui.service.project.internal.ProjectServiceImpl) InstanceViewServiceImpl(eu.esdihumboldt.hale.ui.service.instance.sample.internal.InstanceViewServiceImpl) PopulationServiceImpl(eu.esdihumboldt.hale.ui.service.population.internal.PopulationServiceImpl) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) InstanceSampleServiceImpl(eu.esdihumboldt.hale.ui.service.instance.sample.internal.InstanceSampleServiceImpl) SchemaServiceImpl(eu.esdihumboldt.hale.ui.service.schema.internal.SchemaServiceImpl) InstanceProcessor(eu.esdihumboldt.hale.common.instance.processing.InstanceProcessor) RecentResourcesService(eu.esdihumboldt.hale.ui.service.project.internal.resources.RecentResourcesService) InstanceServiceAdapter(eu.esdihumboldt.hale.ui.service.instance.InstanceServiceAdapter) PreferencesGroovyService(eu.esdihumboldt.hale.ui.service.groovy.internal.PreferencesGroovyService) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) InstanceValidationServiceImpl(eu.esdihumboldt.hale.ui.service.instance.validation.internal.InstanceValidationServiceImpl) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) IOException(java.io.IOException) ReportServiceImpl(eu.esdihumboldt.hale.ui.service.report.internal.ReportServiceImpl) RecentProjectsServiceImpl(eu.esdihumboldt.hale.ui.service.project.internal.RecentProjectsServiceImpl) EntityDefinitionServiceImpl(eu.esdihumboldt.hale.ui.service.entity.internal.EntityDefinitionServiceImpl) InstanceProcessingExtension(eu.esdihumboldt.hale.common.instance.processing.InstanceProcessingExtension) AlignmentServiceImpl(eu.esdihumboldt.hale.ui.service.align.internal.AlignmentServiceImpl) SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) ProjectGeometrySchemaService(eu.esdihumboldt.hale.ui.service.geometry.ProjectGeometrySchemaService) GeometrySchemaService(eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService) OrientInstanceService(eu.esdihumboldt.hale.ui.service.instance.internal.orient.OrientInstanceService) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) OccurringValuesServiceImpl(eu.esdihumboldt.hale.ui.service.values.internal.OccurringValuesServiceImpl) ProjectGeometrySchemaService(eu.esdihumboldt.hale.ui.service.geometry.ProjectGeometrySchemaService)

Example 3 with InstanceService

use of eu.esdihumboldt.hale.ui.service.instance.InstanceService in project hale by halestudio.

the class InstanceImportAdvisor method handleResults.

/**
 * @see IOAdvisor#handleResults(IOProvider)
 */
@Override
public void handleResults(InstanceReader provider) {
    // add instances to instance service
    InstanceService is = getService(InstanceService.class);
    InstanceCollection instances = provider.getInstances();
    ResourceIterator<Instance> it = instances.iterator();
    try {
        if (!it.hasNext()) {
            URI loc = provider.getSource().getLocation();
            if (loc != null) {
                log.warn(MessageFormat.format("No instances could be imported with the given configuration from {0}", loc.toString()));
            } else {
                log.warn("No instances could be imported with the given configuration.");
            }
        }
    } finally {
        it.close();
    }
    // apply sampling before adding to the instance service
    InstanceViewService ivs = PlatformUI.getWorkbench().getService(InstanceViewService.class);
    if (ivs != null) {
        instances = ivs.sample(instances);
    }
    is.addSourceInstances(instances);
    super.handleResults(provider);
}
Also used : InstanceViewService(eu.esdihumboldt.hale.ui.service.instance.sample.InstanceViewService) Instance(eu.esdihumboldt.hale.common.instance.model.Instance) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) URI(java.net.URI)

Example 4 with InstanceService

use of eu.esdihumboldt.hale.ui.service.instance.InstanceService in project hale by halestudio.

the class SourceInstanceExportAdvisor method prepareProvider.

/**
 * @see IOAdvisor#prepareProvider(IOProvider)
 */
@Override
public void prepareProvider(InstanceWriter provider) {
    super.prepareProvider(provider);
    // set target schema
    SchemaService ss = getService(SchemaService.class);
    provider.setTargetSchema(ss.getSchemas(SchemaSpaceID.SOURCE));
    // set instances to export
    InstanceService is = getService(InstanceService.class);
    provider.setInstances(is.getInstances(DataSet.SOURCE));
}
Also used : SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService)

Example 5 with InstanceService

use of eu.esdihumboldt.hale.ui.service.instance.InstanceService in project hale by halestudio.

the class TypeStyleHandler method collectTypesFromSelection.

/**
 * Collect all type definitions and data sets from the current selection of
 * {@link TypeDefinition}s, {@link EntityDefinition}s, {@link Instance}s and
 * {@link InstanceReference}s.
 *
 * @param event the handler execution event
 * @return the collected type definitions
 */
public static SetMultimap<DataSet, TypeDefinition> collectTypesFromSelection(ExecutionEvent event) {
    SetMultimap<DataSet, TypeDefinition> types = HashMultimap.create();
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
        for (Object object : ((IStructuredSelection) selection).toArray()) {
            if (object instanceof TypeDefinition) {
                TypeDefinition type = (TypeDefinition) object;
                if (!types.containsValue(type)) {
                    DataSet dataSet = findDataSet(type);
                    types.put(dataSet, type);
                }
            }
            if (object instanceof EntityDefinition) {
                EntityDefinition entityDef = (EntityDefinition) object;
                if (entityDef.getPropertyPath().isEmpty()) {
                    DataSet dataSet = (entityDef.getSchemaSpace() == SchemaSpaceID.SOURCE) ? (DataSet.SOURCE) : (DataSet.TRANSFORMED);
                    types.put(dataSet, entityDef.getType());
                }
            }
            if (object instanceof InstanceReference) {
                InstanceService is = HandlerUtil.getActiveWorkbenchWindow(event).getWorkbench().getService(InstanceService.class);
                object = is.getInstance((InstanceReference) object);
            }
            if (object instanceof Instance) {
                Instance instance = (Instance) object;
                types.put(instance.getDataSet(), instance.getDefinition());
            }
        }
    }
    return types;
}
Also used : EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) DataSet(eu.esdihumboldt.hale.common.instance.model.DataSet) Instance(eu.esdihumboldt.hale.common.instance.model.Instance) InstanceReference(eu.esdihumboldt.hale.common.instance.model.InstanceReference) ISelection(org.eclipse.jface.viewers.ISelection) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Aggregations

InstanceService (eu.esdihumboldt.hale.ui.service.instance.InstanceService)21 Instance (eu.esdihumboldt.hale.common.instance.model.Instance)6 InstanceReference (eu.esdihumboldt.hale.common.instance.model.InstanceReference)5 GeometrySchemaService (eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService)5 InstanceCollection (eu.esdihumboldt.hale.common.instance.model.InstanceCollection)4 DataSet (eu.esdihumboldt.hale.common.instance.model.DataSet)3 StyleService (eu.esdihumboldt.hale.ui.common.service.style.StyleService)3 ProjectService (eu.esdihumboldt.hale.ui.service.project.ProjectService)3 SchemaService (eu.esdihumboldt.hale.ui.service.schema.SchemaService)3 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)2 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)2 InstanceServiceAdapter (eu.esdihumboldt.hale.ui.service.instance.InstanceServiceAdapter)2 ISelectionService (org.eclipse.ui.ISelectionService)2 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)1 Point (com.vividsolutions.jts.geom.Point)1 ITileOverlayService (de.fhg.igd.mapviewer.view.overlay.ITileOverlayService)1 TileOverlayFactory (de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory)1 SelectableWaypoint (de.fhg.igd.mapviewer.waypoints.SelectableWaypoint)1 PropertyParameter (eu.esdihumboldt.hale.common.align.extension.function.PropertyParameter)1 PropertyParameterDefinition (eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition)1