Package com.opengamma

Examples of com.opengamma.DataNotFoundException


@Test(groups = TestGroup.UNIT)
public class DataNotFoundExceptionMapperTest extends AbstractExceptionMapperTestHelper {

  @Test(dataProvider="mediaTypes")
  public void test_mapping(MediaType mediaType) throws Exception {
    DataNotFoundException ex = new DataNotFoundException("Test message");
    DataNotFoundExceptionMapper mapper = new DataNotFoundExceptionMapper();
    init(mapper, mediaType);
   
    Response test = mapper.toResponse(ex);
    testResult(test, Status.NOT_FOUND, ex);
View Full Code Here


    final PortfolioDocumentExtractor extractor = new PortfolioDocumentExtractor(true, false);
    final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
    final String sql = getElSqlBundle().getSql("GetNodeByOidInstants", args);
    final List<PortfolioDocument> docs = namedJdbc.query(sql, args, extractor);
    if (docs.isEmpty()) {
      throw new DataNotFoundException("Node not found: " + uniqueId);
    }
    return docs.get(0).getPortfolio().getRootNode(); // SQL loads desired node in place of the root node
  }
View Full Code Here

    final PortfolioDocumentExtractor extractor = new PortfolioDocumentExtractor(true, false);
    final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
    final String sql = getElSqlBundle().getSql("GetNodeById", args);
    final List<PortfolioDocument> docs = namedJdbc.query(sql, args, extractor);
    if (docs.isEmpty()) {
      throw new DataNotFoundException("Node not found: " + uniqueId);
    }
    return docs.get(0).getPortfolio().getRootNode(); // SQL loads desired node in place of the root node
  }
View Full Code Here

      public RiskRun doInHibernate(final Session session) throws HibernateException, SQLException {
        final RiskRun run = _dbBatchWriter.getRiskRunById(id);
        if (run != null) {
          return run;
        } else {
          throw new DataNotFoundException("Batch run not found: " + id);
        }
      }
    });
  }
View Full Code Here

  }

  protected RiskRun getRiskRun(ObjectId batchId) {
    RiskRun run = findRiskRunInDb(batchId);
    if (run == null) {
      throw new DataNotFoundException("Cannot find run in database for " + batchId);
    } else {
      return run;
    }
  }
View Full Code Here

  }

  private Position getPosition(final ObjectId positionId) {
    Position position = _positions.get(positionId);
    if (position == null) {
      throw new DataNotFoundException("Unable to find position: " + positionId);
    }
    return position;
  }
View Full Code Here

      portfolio = _portfolios.get(objectId);
    }
    if (portfolio instanceof Portfolio) {
      return (Portfolio) portfolio;
    }
    throw new DataNotFoundException("Unable to find portfolio: " + objectId);
  }
View Full Code Here

  @Override
  public PortfolioNode getPortfolioNode(UniqueId nodeId, final VersionCorrection versionCorrection) {
    PortfolioNode node = _nodes.get(nodeId);
    if (node == null) {
      throw new DataNotFoundException("Unable to find node: " + nodeId);
    }
    return node;
  }
View Full Code Here

  @Override
  public Trade getTrade(UniqueId tradeId) {
    Trade trade = _trades.get(tradeId);
    if (trade == null) {
      throw new DataNotFoundException("Unable to find trade: " + tradeId);
    }
    return trade;
  }
View Full Code Here

    Map<String, Class<?>> parameters = parametersDelegate.getParameters();
    for (Map.Entry<String, Class<?>> entry : parameters.entrySet()) {
      String varName = entry.getKey();
      Class<?> varType = entry.getValue();
      if (!binding.hasVariable(varName)) {
        throw new DataNotFoundException("Parameter named " + varName + " not found");
      }
      Object varValue = binding.getVariable(varName);
      if (!varType.isInstance(varValue)) {
        throw new IllegalArgumentException("Parameter " + varName + " has type " + varValue.getClass().getName() + ", " +
                                                "required type is " + varType.getName());
View Full Code Here

TOP

Related Classes of com.opengamma.DataNotFoundException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.