org.rhq.enterprise.server.sync.importers
Class MetricTemplateImporter

java.lang.Object
  extended by org.rhq.enterprise.server.sync.importers.MetricTemplateImporter
All Implemented Interfaces:
Importer<org.rhq.core.domain.measurement.MeasurementDefinition,org.rhq.core.domain.sync.entity.MetricTemplate>

public class MetricTemplateImporter
extends Object
implements Importer<org.rhq.core.domain.measurement.MeasurementDefinition,org.rhq.core.domain.sync.entity.MetricTemplate>

Author:
Lukas Krejci

Field Summary
static String METRIC_NAME_PROPERTY
           
static String METRIC_UPDATE_OVERRIDE_PROPERTY
           
static String METRIC_UPDATE_OVERRIDES_PROPERTY
           
static String RESOURCE_TYPE_NAME_PROPERTY
           
static String RESOURCE_TYPE_PLUGIN_PROPERTY
           
static String UPDATE_ALL_SCHEDULES_PROPERTY
           
static String UPDATE_SCHEDULES_PROPERTY
           
 
Constructor Summary
MetricTemplateImporter(org.rhq.core.domain.auth.Subject subject, javax.persistence.EntityManager entityManager)
           
MetricTemplateImporter(org.rhq.core.domain.auth.Subject subject, javax.persistence.EntityManager entityManager, MeasurementScheduleManagerLocal measurementScheduleManager)
           
 
Method Summary
 void configure(org.rhq.core.domain.configuration.Configuration configuration)
          Configures the importer.
 String finishImport()
          Finishes the import.
 Set<EntityValidator<org.rhq.core.domain.sync.entity.MetricTemplate>> getEntityValidators()
          The set of entity validators that should be called on each entity before the import actually starts.
 ExportedEntityMatcher<org.rhq.core.domain.measurement.MeasurementDefinition,org.rhq.core.domain.sync.entity.MetricTemplate> getExportedEntityMatcher()
          Returns an entity matcher that can match the entities from the export file with the real entities in the database.
 org.rhq.core.domain.configuration.definition.ConfigurationDefinition getImportConfigurationDefinition()
          A configuration definition describing the configuration of the importer and the default values for individual properties.
static String getUnmatchedMetricTemplatesReport(Set<org.rhq.core.domain.sync.entity.MetricTemplate> metricTemplates)
           
 org.rhq.core.domain.sync.entity.MetricTemplate unmarshallExportedEntity(ExportReader reader)
          Unmarshalls an entity from the provided reader.
 void update(org.rhq.core.domain.measurement.MeasurementDefinition entity, org.rhq.core.domain.sync.entity.MetricTemplate exportedEntity)
          Updates the entity with the data from the export.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UPDATE_ALL_SCHEDULES_PROPERTY

public static final String UPDATE_ALL_SCHEDULES_PROPERTY
See Also:
Constant Field Values

METRIC_NAME_PROPERTY

public static final String METRIC_NAME_PROPERTY
See Also:
Constant Field Values

RESOURCE_TYPE_NAME_PROPERTY

public static final String RESOURCE_TYPE_NAME_PROPERTY
See Also:
Constant Field Values

RESOURCE_TYPE_PLUGIN_PROPERTY

public static final String RESOURCE_TYPE_PLUGIN_PROPERTY
See Also:
Constant Field Values

UPDATE_SCHEDULES_PROPERTY

public static final String UPDATE_SCHEDULES_PROPERTY
See Also:
Constant Field Values

METRIC_UPDATE_OVERRIDES_PROPERTY

public static final String METRIC_UPDATE_OVERRIDES_PROPERTY
See Also:
Constant Field Values

METRIC_UPDATE_OVERRIDE_PROPERTY

public static final String METRIC_UPDATE_OVERRIDE_PROPERTY
See Also:
Constant Field Values
Constructor Detail

MetricTemplateImporter

public MetricTemplateImporter(org.rhq.core.domain.auth.Subject subject,
                              javax.persistence.EntityManager entityManager)

MetricTemplateImporter

public MetricTemplateImporter(org.rhq.core.domain.auth.Subject subject,
                              javax.persistence.EntityManager entityManager,
                              MeasurementScheduleManagerLocal measurementScheduleManager)
Method Detail

getImportConfigurationDefinition

public org.rhq.core.domain.configuration.definition.ConfigurationDefinition getImportConfigurationDefinition()
Description copied from interface: Importer
A configuration definition describing the configuration of the importer and the default values for individual properties.

The returned configuration definition MUST define a default template.

Specified by:
getImportConfigurationDefinition in interface Importer<org.rhq.core.domain.measurement.MeasurementDefinition,org.rhq.core.domain.sync.entity.MetricTemplate>

configure

public void configure(org.rhq.core.domain.configuration.Configuration configuration)
Description copied from interface: Importer
Configures the importer.

Specified by:
configure in interface Importer<org.rhq.core.domain.measurement.MeasurementDefinition,org.rhq.core.domain.sync.entity.MetricTemplate>
Parameters:
configuration - the configuration of the import as defined by the Importer.getImportConfigurationDefinition()

getExportedEntityMatcher

public ExportedEntityMatcher<org.rhq.core.domain.measurement.MeasurementDefinition,org.rhq.core.domain.sync.entity.MetricTemplate> getExportedEntityMatcher()
Description copied from interface: Importer
Returns an entity matcher that can match the entities from the export file with the real entities in the database.

Specified by:
getExportedEntityMatcher in interface Importer<org.rhq.core.domain.measurement.MeasurementDefinition,org.rhq.core.domain.sync.entity.MetricTemplate>
Returns:

getEntityValidators

public Set<EntityValidator<org.rhq.core.domain.sync.entity.MetricTemplate>> getEntityValidators()
Description copied from interface: Importer
The set of entity validators that should be called on each entity before the import actually starts.

Specified by:
getEntityValidators in interface Importer<org.rhq.core.domain.measurement.MeasurementDefinition,org.rhq.core.domain.sync.entity.MetricTemplate>

update

public void update(org.rhq.core.domain.measurement.MeasurementDefinition entity,
                   org.rhq.core.domain.sync.entity.MetricTemplate exportedEntity)
Description copied from interface: Importer
Updates the entity with the data from the export.

This method is responsible for persisting the entity in the database using the provided entityManager. Note that the actual persist can also be delayed until the Importer.finishImport() method is called so that the importer can take advantage of batching.

Specified by:
update in interface Importer<org.rhq.core.domain.measurement.MeasurementDefinition,org.rhq.core.domain.sync.entity.MetricTemplate>
Parameters:
entity - the entity to persist (may be null if the Importer.getExportedEntityMatcher() returned null of if the entity matcher didn't find a match)
exportedEntity - the entity found in the export file that should be used to update the entity in the database

unmarshallExportedEntity

public org.rhq.core.domain.sync.entity.MetricTemplate unmarshallExportedEntity(ExportReader reader)
                                                                        throws XMLStreamException
Description copied from interface: Importer
Unmarshalls an entity from the provided reader.

Specified by:
unmarshallExportedEntity in interface Importer<org.rhq.core.domain.measurement.MeasurementDefinition,org.rhq.core.domain.sync.entity.MetricTemplate>
Returns:
Throws:
XMLStreamException

finishImport

public String finishImport()
Description copied from interface: Importer
Finishes the import. This method is called after all entities from the export file have been updated.

This is useful for importers that need to batch the updates to the database.

Specified by:
finishImport in interface Importer<org.rhq.core.domain.measurement.MeasurementDefinition,org.rhq.core.domain.sync.entity.MetricTemplate>
Returns:
notes that should be transfered to the user. These should be any warnings and other messages that are not errors (which should throw an exception) but are deemed important for the (human) caller to be aware of.

getUnmatchedMetricTemplatesReport

public static String getUnmatchedMetricTemplatesReport(Set<org.rhq.core.domain.sync.entity.MetricTemplate> metricTemplates)


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.