Package org.molgenis.model.elements

Examples of org.molgenis.model.elements.Model


  public void testNotAuthenticated() throws Exception
  {
    MockDatabase db = new MockDatabase();
    db.setLogin(new MockLogin(false));

    Model model = when(mock(Model.class).getEntities(false, false)).thenReturn(new Vector<Entity>()).getMock();
    db.setMetaData(model);

    molgenisRequest.setDatabase(db);
    molgenisRequest.setServicePath(API_FIND_URI);
    mockHttpServletRequest.setPathInfo(API_FIND_URI + "/");
View Full Code Here


  public void testAuthenticated() throws Exception
  {
    MockDatabase db = new MockDatabase();
    db.setLogin(new MockLogin(true));

    Model model = when(mock(Model.class).getEntities(false, false)).thenReturn(new Vector<Entity>()).getMock();
    db.setMetaData(model);

    molgenisRequest.setDatabase(db);
    molgenisRequest.setServicePath(API_FIND_URI);
    mockHttpServletRequest.setPathInfo(API_FIND_URI + "/");
View Full Code Here

  public void testNotExistingOrSystemEntity() throws ParseException, DatabaseException, IOException
  {
    MockDatabase db = new MockDatabase();
    db.setLogin(new MockLogin(true));

    Model model = when(mock(Model.class).getEntities(false, false)).thenReturn(new Vector<Entity>()).getMock();
    db.setMetaData(model);

    molgenisRequest.setDatabase(db);
    molgenisRequest.setServicePath(API_FIND_URI);
    mockHttpServletRequest.setPathInfo(API_FIND_URI + "/XXXX");
View Full Code Here

  @BeforeSuite
  public static void setUpBeforeSuite() throws Exception
  {
    // create test model
    Model model = getModel();
    if (model == null || model.getModules() == null || model.getModules().isEmpty())
    {
      throw new MolgenisModelException("model should contain at least one module");
    }
    MODEL = model;
    MODEL_OPTIONS = new MolgenisOptions();
View Full Code Here

        + "      <field name=\"feature\" type=\"xref\" xref_entity=\"Feature\" />\n" + "    </entity>\n"
        + "  </module>\n" + "</molgenis>";

    // TODO programmatically define model instead of parsing from XML
    // generate model
    Model model = MolgenisModelParser.parseDbSchema(xml);
    // validate model & resolve model dependencies
    MolgenisModelValidator.validate(model, new MolgenisOptions());
    return model;
  }
View Full Code Here

{
  private static final Logger logger = Logger.getLogger(MolgenisModel.class.getSimpleName());

  public static Model parse(MolgenisOptions options) throws Exception
  {
    Model model = null;

    try
    {
      logger.info("parsing db-schema from " + options.model_database);

      // 19-4-2011 ER: unused code, so commented out!
      // ArrayList<String> db_files = options.model_database;
      // for (int i = 0; i < db_files.size(); i++)
      // db_files.set(i, options.path + db_files.get(i));

      model = MolgenisModelParser.parseDbSchema(options.model_database);

      // Get the strings of the property 'authorizable' and add the entity
      // name
      // 'Authorizable' to the list of Implements. Solves datamodel
      // duplication
      // in molgenis_apps suite. Possible future work: put auth
      // dependencies into
      // molgenis itself so it becomes generic across projects.
      for (String eName : options.authorizable)
      {
        eName = eName.trim(); // allow e.g. 'Observation, Investigation'
        Vector<String> implNames = model.getEntity(eName).getImplementsNames();
        if (!implNames.contains("Authorizable"))
        {
          implNames.add("Authorizable");
          model.getEntity(eName).setImplements(implNames);
        }
      }

      logger.debug("read: " + model);
View Full Code Here

  }

  /** Simple parse an xml string */
  public static Model parseDbSchema(String xml) throws MolgenisModelException
  {
    Model model = new Model("molgenis");

    try
    {
      DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

View Full Code Here

  }

  // db parser
  public static Model parseDbSchema(ArrayList<String> filenames) throws MolgenisModelException
  {
    Model model = new Model("molgenis");
    Document document = null;

    // initialize the document
    for (String filename : filenames)
    {
View Full Code Here

TOP

Related Classes of org.molgenis.model.elements.Model

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.