/** * Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.integration.component; import java.util.LinkedHashMap; import java.util.Map; import org.joda.beans.Bean; import org.joda.beans.BeanBuilder; import org.joda.beans.BeanDefinition; import org.joda.beans.JodaBeanUtils; import org.joda.beans.MetaProperty; import org.joda.beans.Property; import org.joda.beans.PropertyDefinition; import org.joda.beans.impl.direct.DirectBeanBuilder; import org.joda.beans.impl.direct.DirectMetaProperty; import org.joda.beans.impl.direct.DirectMetaPropertyMap; import com.opengamma.bbg.referencedata.ReferenceDataProvider; import com.opengamma.component.ComponentRepository; import com.opengamma.component.factory.AbstractComponentFactory; import com.opengamma.integration.copier.portfolio.web.PortfolioLoaderResource; import com.opengamma.master.historicaltimeseries.HistoricalTimeSeriesMaster; import com.opengamma.master.portfolio.PortfolioMaster; import com.opengamma.master.position.PositionMaster; import com.opengamma.master.security.SecurityMaster; import com.opengamma.provider.historicaltimeseries.HistoricalTimeSeriesProvider; import com.opengamma.provider.security.SecurityProvider; /** * Factory for registering REST components from the OG-Integration project that can't be configured with the other * REST resources because they're not available to the OG-Web project component factories. */ @BeanDefinition public class IntegrationWebComponentFactory extends AbstractComponentFactory { /** * The portfolio master. */ @PropertyDefinition(validate = "notNull") private PortfolioMaster _portfolioMaster; /** * The position master. */ @PropertyDefinition(validate = "notNull") private PositionMaster _positionMaster; /** * The security master. */ @PropertyDefinition(validate = "notNull") private SecurityMaster _securityMaster; /** * The time-series master. */ @PropertyDefinition(validate = "notNull") private HistoricalTimeSeriesMaster _historicalTimeSeriesMaster; /** * The security provider for the underlying data source. */ @PropertyDefinition(validate = "notNull") private SecurityProvider _securityProvider; /** * The time-series provider for the underlying data source. */ @PropertyDefinition(validate = "notNull") private HistoricalTimeSeriesProvider _historicalTimeSeriesProvider; /** * The reference data provider for the underlying data source. */ @PropertyDefinition(validate = "notNull") private ReferenceDataProvider _bloombergReferenceDataProvider; //------------------------------------------------------------------------- @Override public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception { repo.getRestComponents().publishResource(new PortfolioLoaderResource( getPortfolioMaster(), getPositionMaster(), getSecurityMaster(), getHistoricalTimeSeriesMaster(), getSecurityProvider(), getHistoricalTimeSeriesProvider(), getBloombergReferenceDataProvider())); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code IntegrationWebComponentFactory}. * @return the meta-bean, not null */ public static IntegrationWebComponentFactory.Meta meta() { return IntegrationWebComponentFactory.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(IntegrationWebComponentFactory.Meta.INSTANCE); } @Override public IntegrationWebComponentFactory.Meta metaBean() { return IntegrationWebComponentFactory.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the portfolio master. * @return the value of the property, not null */ public PortfolioMaster getPortfolioMaster() { return _portfolioMaster; } /** * Sets the portfolio master. * @param portfolioMaster the new value of the property, not null */ public void setPortfolioMaster(PortfolioMaster portfolioMaster) { JodaBeanUtils.notNull(portfolioMaster, "portfolioMaster"); this._portfolioMaster = portfolioMaster; } /** * Gets the the {@code portfolioMaster} property. * @return the property, not null */ public final Property<PortfolioMaster> portfolioMaster() { return metaBean().portfolioMaster().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the position master. * @return the value of the property, not null */ public PositionMaster getPositionMaster() { return _positionMaster; } /** * Sets the position master. * @param positionMaster the new value of the property, not null */ public void setPositionMaster(PositionMaster positionMaster) { JodaBeanUtils.notNull(positionMaster, "positionMaster"); this._positionMaster = positionMaster; } /** * Gets the the {@code positionMaster} property. * @return the property, not null */ public final Property<PositionMaster> positionMaster() { return metaBean().positionMaster().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the security master. * @return the value of the property, not null */ public SecurityMaster getSecurityMaster() { return _securityMaster; } /** * Sets the security master. * @param securityMaster the new value of the property, not null */ public void setSecurityMaster(SecurityMaster securityMaster) { JodaBeanUtils.notNull(securityMaster, "securityMaster"); this._securityMaster = securityMaster; } /** * Gets the the {@code securityMaster} property. * @return the property, not null */ public final Property<SecurityMaster> securityMaster() { return metaBean().securityMaster().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the time-series master. * @return the value of the property, not null */ public HistoricalTimeSeriesMaster getHistoricalTimeSeriesMaster() { return _historicalTimeSeriesMaster; } /** * Sets the time-series master. * @param historicalTimeSeriesMaster the new value of the property, not null */ public void setHistoricalTimeSeriesMaster(HistoricalTimeSeriesMaster historicalTimeSeriesMaster) { JodaBeanUtils.notNull(historicalTimeSeriesMaster, "historicalTimeSeriesMaster"); this._historicalTimeSeriesMaster = historicalTimeSeriesMaster; } /** * Gets the the {@code historicalTimeSeriesMaster} property. * @return the property, not null */ public final Property<HistoricalTimeSeriesMaster> historicalTimeSeriesMaster() { return metaBean().historicalTimeSeriesMaster().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the security provider for the underlying data source. * @return the value of the property, not null */ public SecurityProvider getSecurityProvider() { return _securityProvider; } /** * Sets the security provider for the underlying data source. * @param securityProvider the new value of the property, not null */ public void setSecurityProvider(SecurityProvider securityProvider) { JodaBeanUtils.notNull(securityProvider, "securityProvider"); this._securityProvider = securityProvider; } /** * Gets the the {@code securityProvider} property. * @return the property, not null */ public final Property<SecurityProvider> securityProvider() { return metaBean().securityProvider().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the time-series provider for the underlying data source. * @return the value of the property, not null */ public HistoricalTimeSeriesProvider getHistoricalTimeSeriesProvider() { return _historicalTimeSeriesProvider; } /** * Sets the time-series provider for the underlying data source. * @param historicalTimeSeriesProvider the new value of the property, not null */ public void setHistoricalTimeSeriesProvider(HistoricalTimeSeriesProvider historicalTimeSeriesProvider) { JodaBeanUtils.notNull(historicalTimeSeriesProvider, "historicalTimeSeriesProvider"); this._historicalTimeSeriesProvider = historicalTimeSeriesProvider; } /** * Gets the the {@code historicalTimeSeriesProvider} property. * @return the property, not null */ public final Property<HistoricalTimeSeriesProvider> historicalTimeSeriesProvider() { return metaBean().historicalTimeSeriesProvider().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the reference data provider for the underlying data source. * @return the value of the property, not null */ public ReferenceDataProvider getBloombergReferenceDataProvider() { return _bloombergReferenceDataProvider; } /** * Sets the reference data provider for the underlying data source. * @param bloombergReferenceDataProvider the new value of the property, not null */ public void setBloombergReferenceDataProvider(ReferenceDataProvider bloombergReferenceDataProvider) { JodaBeanUtils.notNull(bloombergReferenceDataProvider, "bloombergReferenceDataProvider"); this._bloombergReferenceDataProvider = bloombergReferenceDataProvider; } /** * Gets the the {@code bloombergReferenceDataProvider} property. * @return the property, not null */ public final Property<ReferenceDataProvider> bloombergReferenceDataProvider() { return metaBean().bloombergReferenceDataProvider().createProperty(this); } //----------------------------------------------------------------------- @Override public IntegrationWebComponentFactory clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { IntegrationWebComponentFactory other = (IntegrationWebComponentFactory) obj; return JodaBeanUtils.equal(getPortfolioMaster(), other.getPortfolioMaster()) && JodaBeanUtils.equal(getPositionMaster(), other.getPositionMaster()) && JodaBeanUtils.equal(getSecurityMaster(), other.getSecurityMaster()) && JodaBeanUtils.equal(getHistoricalTimeSeriesMaster(), other.getHistoricalTimeSeriesMaster()) && JodaBeanUtils.equal(getSecurityProvider(), other.getSecurityProvider()) && JodaBeanUtils.equal(getHistoricalTimeSeriesProvider(), other.getHistoricalTimeSeriesProvider()) && JodaBeanUtils.equal(getBloombergReferenceDataProvider(), other.getBloombergReferenceDataProvider()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getPortfolioMaster()); hash = hash * 31 + JodaBeanUtils.hashCode(getPositionMaster()); hash = hash * 31 + JodaBeanUtils.hashCode(getSecurityMaster()); hash = hash * 31 + JodaBeanUtils.hashCode(getHistoricalTimeSeriesMaster()); hash = hash * 31 + JodaBeanUtils.hashCode(getSecurityProvider()); hash = hash * 31 + JodaBeanUtils.hashCode(getHistoricalTimeSeriesProvider()); hash = hash * 31 + JodaBeanUtils.hashCode(getBloombergReferenceDataProvider()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(256); buf.append("IntegrationWebComponentFactory{"); int len = buf.length(); toString(buf); if (buf.length() > len) { buf.setLength(buf.length() - 2); } buf.append('}'); return buf.toString(); } @Override protected void toString(StringBuilder buf) { super.toString(buf); buf.append("portfolioMaster").append('=').append(JodaBeanUtils.toString(getPortfolioMaster())).append(',').append(' '); buf.append("positionMaster").append('=').append(JodaBeanUtils.toString(getPositionMaster())).append(',').append(' '); buf.append("securityMaster").append('=').append(JodaBeanUtils.toString(getSecurityMaster())).append(',').append(' '); buf.append("historicalTimeSeriesMaster").append('=').append(JodaBeanUtils.toString(getHistoricalTimeSeriesMaster())).append(',').append(' '); buf.append("securityProvider").append('=').append(JodaBeanUtils.toString(getSecurityProvider())).append(',').append(' '); buf.append("historicalTimeSeriesProvider").append('=').append(JodaBeanUtils.toString(getHistoricalTimeSeriesProvider())).append(',').append(' '); buf.append("bloombergReferenceDataProvider").append('=').append(JodaBeanUtils.toString(getBloombergReferenceDataProvider())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code IntegrationWebComponentFactory}. */ public static class Meta extends AbstractComponentFactory.Meta { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code portfolioMaster} property. */ private final MetaProperty<PortfolioMaster> _portfolioMaster = DirectMetaProperty.ofReadWrite( this, "portfolioMaster", IntegrationWebComponentFactory.class, PortfolioMaster.class); /** * The meta-property for the {@code positionMaster} property. */ private final MetaProperty<PositionMaster> _positionMaster = DirectMetaProperty.ofReadWrite( this, "positionMaster", IntegrationWebComponentFactory.class, PositionMaster.class); /** * The meta-property for the {@code securityMaster} property. */ private final MetaProperty<SecurityMaster> _securityMaster = DirectMetaProperty.ofReadWrite( this, "securityMaster", IntegrationWebComponentFactory.class, SecurityMaster.class); /** * The meta-property for the {@code historicalTimeSeriesMaster} property. */ private final MetaProperty<HistoricalTimeSeriesMaster> _historicalTimeSeriesMaster = DirectMetaProperty.ofReadWrite( this, "historicalTimeSeriesMaster", IntegrationWebComponentFactory.class, HistoricalTimeSeriesMaster.class); /** * The meta-property for the {@code securityProvider} property. */ private final MetaProperty<SecurityProvider> _securityProvider = DirectMetaProperty.ofReadWrite( this, "securityProvider", IntegrationWebComponentFactory.class, SecurityProvider.class); /** * The meta-property for the {@code historicalTimeSeriesProvider} property. */ private final MetaProperty<HistoricalTimeSeriesProvider> _historicalTimeSeriesProvider = DirectMetaProperty.ofReadWrite( this, "historicalTimeSeriesProvider", IntegrationWebComponentFactory.class, HistoricalTimeSeriesProvider.class); /** * The meta-property for the {@code bloombergReferenceDataProvider} property. */ private final MetaProperty<ReferenceDataProvider> _bloombergReferenceDataProvider = DirectMetaProperty.ofReadWrite( this, "bloombergReferenceDataProvider", IntegrationWebComponentFactory.class, ReferenceDataProvider.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "portfolioMaster", "positionMaster", "securityMaster", "historicalTimeSeriesMaster", "securityProvider", "historicalTimeSeriesProvider", "bloombergReferenceDataProvider"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case -772274742: // portfolioMaster return _portfolioMaster; case -1840419605: // positionMaster return _positionMaster; case -887218750: // securityMaster return _securityMaster; case 173967376: // historicalTimeSeriesMaster return _historicalTimeSeriesMaster; case 809869649: // securityProvider return _securityProvider; case -1592479713: // historicalTimeSeriesProvider return _historicalTimeSeriesProvider; case -245204181: // bloombergReferenceDataProvider return _bloombergReferenceDataProvider; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends IntegrationWebComponentFactory> builder() { return new DirectBeanBuilder<IntegrationWebComponentFactory>(new IntegrationWebComponentFactory()); } @Override public Class<? extends IntegrationWebComponentFactory> beanType() { return IntegrationWebComponentFactory.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code portfolioMaster} property. * @return the meta-property, not null */ public final MetaProperty<PortfolioMaster> portfolioMaster() { return _portfolioMaster; } /** * The meta-property for the {@code positionMaster} property. * @return the meta-property, not null */ public final MetaProperty<PositionMaster> positionMaster() { return _positionMaster; } /** * The meta-property for the {@code securityMaster} property. * @return the meta-property, not null */ public final MetaProperty<SecurityMaster> securityMaster() { return _securityMaster; } /** * The meta-property for the {@code historicalTimeSeriesMaster} property. * @return the meta-property, not null */ public final MetaProperty<HistoricalTimeSeriesMaster> historicalTimeSeriesMaster() { return _historicalTimeSeriesMaster; } /** * The meta-property for the {@code securityProvider} property. * @return the meta-property, not null */ public final MetaProperty<SecurityProvider> securityProvider() { return _securityProvider; } /** * The meta-property for the {@code historicalTimeSeriesProvider} property. * @return the meta-property, not null */ public final MetaProperty<HistoricalTimeSeriesProvider> historicalTimeSeriesProvider() { return _historicalTimeSeriesProvider; } /** * The meta-property for the {@code bloombergReferenceDataProvider} property. * @return the meta-property, not null */ public final MetaProperty<ReferenceDataProvider> bloombergReferenceDataProvider() { return _bloombergReferenceDataProvider; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -772274742: // portfolioMaster return ((IntegrationWebComponentFactory) bean).getPortfolioMaster(); case -1840419605: // positionMaster return ((IntegrationWebComponentFactory) bean).getPositionMaster(); case -887218750: // securityMaster return ((IntegrationWebComponentFactory) bean).getSecurityMaster(); case 173967376: // historicalTimeSeriesMaster return ((IntegrationWebComponentFactory) bean).getHistoricalTimeSeriesMaster(); case 809869649: // securityProvider return ((IntegrationWebComponentFactory) bean).getSecurityProvider(); case -1592479713: // historicalTimeSeriesProvider return ((IntegrationWebComponentFactory) bean).getHistoricalTimeSeriesProvider(); case -245204181: // bloombergReferenceDataProvider return ((IntegrationWebComponentFactory) bean).getBloombergReferenceDataProvider(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -772274742: // portfolioMaster ((IntegrationWebComponentFactory) bean).setPortfolioMaster((PortfolioMaster) newValue); return; case -1840419605: // positionMaster ((IntegrationWebComponentFactory) bean).setPositionMaster((PositionMaster) newValue); return; case -887218750: // securityMaster ((IntegrationWebComponentFactory) bean).setSecurityMaster((SecurityMaster) newValue); return; case 173967376: // historicalTimeSeriesMaster ((IntegrationWebComponentFactory) bean).setHistoricalTimeSeriesMaster((HistoricalTimeSeriesMaster) newValue); return; case 809869649: // securityProvider ((IntegrationWebComponentFactory) bean).setSecurityProvider((SecurityProvider) newValue); return; case -1592479713: // historicalTimeSeriesProvider ((IntegrationWebComponentFactory) bean).setHistoricalTimeSeriesProvider((HistoricalTimeSeriesProvider) newValue); return; case -245204181: // bloombergReferenceDataProvider ((IntegrationWebComponentFactory) bean).setBloombergReferenceDataProvider((ReferenceDataProvider) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((IntegrationWebComponentFactory) bean)._portfolioMaster, "portfolioMaster"); JodaBeanUtils.notNull(((IntegrationWebComponentFactory) bean)._positionMaster, "positionMaster"); JodaBeanUtils.notNull(((IntegrationWebComponentFactory) bean)._securityMaster, "securityMaster"); JodaBeanUtils.notNull(((IntegrationWebComponentFactory) bean)._historicalTimeSeriesMaster, "historicalTimeSeriesMaster"); JodaBeanUtils.notNull(((IntegrationWebComponentFactory) bean)._securityProvider, "securityProvider"); JodaBeanUtils.notNull(((IntegrationWebComponentFactory) bean)._historicalTimeSeriesProvider, "historicalTimeSeriesProvider"); JodaBeanUtils.notNull(((IntegrationWebComponentFactory) bean)._bloombergReferenceDataProvider, "bloombergReferenceDataProvider"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }