@Mapping(from = StorageServerConnections.class, to = LogicalUnit.class) public static LogicalUnit map(StorageServerConnections entity, LogicalUnit template) { LogicalUnit model = template != null ? template : new LogicalUnit(); model.setAddress(entity.getConnection()); model.setTarget(entity.getIqn()); model.setPort(Integer.parseInt(entity.getPort())); model.setUsername(entity.getUserName()); if (entity.getConnection()!=null && entity.getPort()!=null && entity.getPortal()!=null) { model.setPortal(entity.getConnection() + ":" + entity.getPort() + "," + entity.getPortal()); } return model; }
@Override public List<StorageServerConnections> getAllForConnection( StorageServerConnections connection) { // NOTE - any change to this stored procedure parameters should require a change in // the StorageServerConnections class, as those fields can be set only with null or a // actual value (empty string can't be used). return getCallsHandler().executeReadList("Getstorage_server_connectionsByKey", mapper, getCustomMapSqlParameterSource() .addValue("iqn", connection.getIqn()) .addValue("connection", connection.getConnection()) .addValue("port", connection.getPort()) .addValue("portal", connection.getPortal()) .addValue("username", connection.getUserName())); }
model.setAddress(entity.getConnection()); model.setPort(Integer.parseInt(entity.getPort())); model.setUsername(entity.getUserName()); model.setTarget(entity.getIqn());
private MapSqlParameterSource getFullParameterSource(final StorageServerConnections connection) { return getIdParameterSource(connection.getId()) .addValue("connection", connection.getConnection()) .addValue("iqn", connection.getIqn()) .addValue("port", connection.getPort()) .addValue("portal", connection.getPortal()) .addValue("password", DbFacadeUtils.encryptPassword(connection.getPassword())) .addValue("storage_type", connection.getStorageType()) .addValue("user_name", connection.getUserName()) .addValue("mount_options", connection.getMountOptions()) .addValue("vfs_type", connection.getVfsType()) .addValue("nfs_version", (connection.getNfsVersion() != null) ? connection.getNfsVersion().getValue() : null) .addValue("nfs_timeo", connection.getNfsTimeo()) .addValue("nfs_retrans", connection.getNfsRetrans()) .addValue("gluster_volume_id", connection.getGlusterVolumeId()); }
@Test public void checkISCSISStorageConnectionsMappingsToBll() { StorageServerConnections connection = new StorageServerConnections(); Guid connId = Guid.newGuid(); connection.setId(connId.toString()); connection.setIqn("iqn.my.target1"); connection.setPort("3260"); connection.setStorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType.ISCSI); connection.setConnection("1.2.135.255"); connection.setUserName("myuser1"); connection.setPassword("123"); StorageConnection RESTConnection = new StorageConnection(); RESTConnection.setId(connId.toString()); RESTConnection.setType(StorageType.ISCSI); RESTConnection.setPort(3260); RESTConnection.setTarget("iqn.my.target1"); RESTConnection.setAddress("1.2.135.255"); RESTConnection.setUsername("myuser1"); RESTConnection.setPassword("123"); StorageServerConnections mappedResult = StorageDomainMapper.map(RESTConnection, null); assertEquals(mappedResult.getId(), mappedResult.getId()); assertEquals(mappedResult.getStorageType(), mappedResult.getStorageType()); assertEquals(mappedResult.getConnection(), mappedResult.getConnection()); assertEquals(mappedResult.getIqn(), mappedResult.getIqn()); assertEquals(mappedResult.getUserName(), mappedResult.getUserName()); assertEquals(mappedResult.getPassword(), mappedResult.getPassword()); assertEquals(mappedResult.getPort(), mappedResult.getPort()); }