@Test void addAttribute() { EntityType entityType = when(mock(EntityType.class).getId()).thenReturn("entity").getMock(); Attribute idAttr = when(mock(Attribute.class).getName()).thenReturn("id").getMock(); when(idAttr.getIdentifier()).thenReturn("idAttrId"); when(entityType.getIdAttribute()).thenReturn(idAttr); Attribute attr = when(mock(Attribute.class).getName()).thenReturn("attr").getMock(); when(attr.getIdentifier()).thenReturn("attrId"); when(attr.getDataType()).thenReturn(STRING); postgreSqlRepoCollection.addAttribute(entityType, attr); verify(jdbcTemplate) .execute("ALTER TABLE \"entity#6844280e\" ADD \"attr\" character varying(255) NOT NULL"); verifyNoMoreInteractions(jdbcTemplate); }
@Override public void addAttribute(EntityType entityType, Attribute attr) { if (entityType.isAbstract()) { throw new MolgenisDataException( format( "Cannot add attribute [%s] to abstract entity type [%s].", attr.getName(), entityType.getId())); } if (entityType.getAttribute(attr.getName()) != null) { throw new MolgenisDataException( format( "Adding attribute operation failed. Attribute already exists [%s]", attr.getName())); } addAttributeInternal(entityType, attr); }
PostgreSqlRepositoryCollection extends AbstractRepositoryCollection { @Override public void addAttribute(EntityType entityType, Attribute attr) { if (entityType.isAbstract()) { throw new MolgenisDataException( format( "Cannot add attribute [%s] to abstract entity type [%s].", attr.getName(), entityType.getId())); } if (entityType.getAttribute(attr.getName()) != null) { throw new MolgenisDataException( format( "Adding attribute operation failed. Attribute already exists [%s]", attr.getName())); } addAttributeInternal(entityType, attr); } }
PostgreSqlRepositoryCollection extends AbstractRepositoryCollection { @Override public void addAttribute(EntityType entityType, Attribute attr) { if (entityType.isAbstract()) { throw new MolgenisDataException( format( "Cannot add attribute [%s] to abstract entity type [%s].", attr.getName(), entityType.getId())); } if (entityType.getAttribute(attr.getName()) != null) { throw new MolgenisDataException( format( "Adding attribute operation failed. Attribute already exists [%s]", attr.getName())); } addAttributeInternal(entityType, attr); } PostgreSqlRepositoryCollection(
      PostgreSqlEntityFactory postgreSqlEntityFactory,
      DataSource dataSource,
      JdbcTemplate jdbcTemplate,
      DataService dataService); }
PostgreSqlRepositoryCollection extends AbstractRepositoryCollection { @Override public void addAttribute(EntityType entityType, Attribute attr) { if (entityType.isAbstract()) { throw new MolgenisDataException( format( "Cannot add attribute [%s] to abstract entity type [%s].", attr.getName(), entityType.getId())); } if (entityType.getAttribute(attr.getName()) != null) { throw new MolgenisDataException( format( "Adding attribute operation failed. Attribute already exists [%s]", attr.getName())); } addAttributeInternal(entityType, attr); } PostgreSqlRepositoryCollection(
      PostgreSqlEntityFactory postgreSqlEntityFactory,
      DataSource dataSource,
      JdbcTemplate jdbcTemplate,
      DataService dataService); @Override String getName(); @Override Set<RepositoryCollectionCapability> getCapabilities(); @Override boolean hasRepository(String name); @Override Repository<Entity> createRepository(EntityType entityType); @Override boolean hasRepository(EntityType entityType); @Override Iterable<String> getEntityTypeIds(); @Override Repository<Entity> getRepository(String id); @Override Repository<Entity> getRepository(EntityType entityType); @Override Iterator<Repository<Entity>> iterator(); @Override void deleteRepository(EntityType entityType); @Override void updateRepository(EntityType entityType, EntityType updatedEntityType); @Override void addAttribute(EntityType entityType, Attribute attr); @Override void updateAttribute(EntityType entityType, Attribute attr, Attribute updatedAttr); @Override void deleteAttribute(EntityType entityType, Attribute attr); }
PostgreSqlRepositoryCollection extends AbstractRepositoryCollection { @Override public void addAttribute(EntityType entityType, Attribute attr) { if (entityType.isAbstract()) { throw new MolgenisDataException( format( "Cannot add attribute [%s] to abstract entity type [%s].", attr.getName(), entityType.getId())); } if (entityType.getAttribute(attr.getName()) != null) { throw new MolgenisDataException( format( "Adding attribute operation failed. Attribute already exists [%s]", attr.getName())); } addAttributeInternal(entityType, attr); } PostgreSqlRepositoryCollection(
      PostgreSqlEntityFactory postgreSqlEntityFactory,
      DataSource dataSource,
      JdbcTemplate jdbcTemplate,
      DataService dataService); @Override String getName(); @Override Set<RepositoryCollectionCapability> getCapabilities(); @Override boolean hasRepository(String name); @Override Repository<Entity> createRepository(EntityType entityType); @Override boolean hasRepository(EntityType entityType); @Override Iterable<String> getEntityTypeIds(); @Override Repository<Entity> getRepository(String id); @Override Repository<Entity> getRepository(EntityType entityType); @Override Iterator<Repository<Entity>> iterator(); @Override void deleteRepository(EntityType entityType); @Override void updateRepository(EntityType entityType, EntityType updatedEntityType); @Override void addAttribute(EntityType entityType, Attribute attr); @Override void updateAttribute(EntityType entityType, Attribute attr, Attribute updatedAttr); @Override void deleteAttribute(EntityType entityType, Attribute attr); static final String POSTGRESQL; }