[vlma-devel] commit: The model shouldn't depend on the Data service. (Adrien Grand )
git version control
git at videolan.org
Sun May 11 12:47:18 CEST 2008
vlma | branch: master | Adrien Grand <jpountz at jpountz.net> | Sun May 11 11:33:48 2008 +0200| [f81618330028aa568839f5d8c98f018ccdf2288b]
The model shouldn't depend on the Data service.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=f81618330028aa568839f5d8c98f018ccdf2288b
---
.../main/java/org/videolan/vlma/common/Data.java | 2 +-
.../org/videolan/vlma/common/adapter/Adapter.java | 3 +--
.../videolan/vlma/common/adapter/DVBSAdapter.java | 11 ++---------
.../videolan/vlma/common/adapter/DVBTAdapter.java | 3 +--
.../videolan/vlma/common/adapter/FilesAdapter.java | 3 +--
.../org/videolan/vlma/common/DataMockImpl.java | 2 +-
.../java/org/videolan/vlma/daemon/DataImpl.java | 4 ++--
.../web/server/ServersAdapterAddController.java | 9 +++++++--
8 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/core/src/main/java/org/videolan/vlma/common/Data.java b/core/src/main/java/org/videolan/vlma/common/Data.java
index 485ff7c..ba296c9 100644
--- a/core/src/main/java/org/videolan/vlma/common/Data.java
+++ b/core/src/main/java/org/videolan/vlma/common/Data.java
@@ -266,7 +266,7 @@ public interface Data {
* The adapter has no such parameter.
*/
public void setAdapterParameter(int server, String name, String parameter,
- String value) throws AdapterDoesNotExistException,
+ Object value) throws AdapterDoesNotExistException,
AdapterParameterDoesNotExistException;
/**
diff --git a/core/src/main/java/org/videolan/vlma/common/adapter/Adapter.java b/core/src/main/java/org/videolan/vlma/common/adapter/Adapter.java
index cd4b38c..bc37935 100644
--- a/core/src/main/java/org/videolan/vlma/common/adapter/Adapter.java
+++ b/core/src/main/java/org/videolan/vlma/common/adapter/Adapter.java
@@ -20,7 +20,6 @@
package org.videolan.vlma.common.adapter;
-import org.videolan.vlma.common.Data;
import org.videolan.vlma.common.exception.AdapterParameterDoesNotExistException;
import org.videolan.vlma.common.media.Media;
import org.videolan.vlma.common.server.Server;
@@ -62,7 +61,7 @@ public interface Adapter {
* @throws AdapterParameterDoesNotExistException
* specified parameter is not appropriate
*/
- public void setParameter(String parameter, String value, Data data)
+ public void setParameter(String parameter, Object value)
throws AdapterParameterDoesNotExistException;
/**
diff --git a/core/src/main/java/org/videolan/vlma/common/adapter/DVBSAdapter.java b/core/src/main/java/org/videolan/vlma/common/adapter/DVBSAdapter.java
index 17e327a..770ecdb 100644
--- a/core/src/main/java/org/videolan/vlma/common/adapter/DVBSAdapter.java
+++ b/core/src/main/java/org/videolan/vlma/common/adapter/DVBSAdapter.java
@@ -20,7 +20,6 @@
package org.videolan.vlma.common.adapter;
-import org.videolan.vlma.common.Data;
import org.videolan.vlma.common.exception.AdapterParameterDoesNotExistException;
import org.videolan.vlma.common.media.Media;
import org.videolan.vlma.common.media.SatChannel;
@@ -64,16 +63,10 @@ public class DVBSAdapter extends AbstractAdapter {
this.satellite = satellite;
}
- public void setParameter(String parameter, String value, Data data)
+ public void setParameter(String parameter, Object value)
throws AdapterParameterDoesNotExistException {
if (parameter.equalsIgnoreCase("satellite")) {
- this.setSatellite(null);
- for (Satellite s : data.getSatellites()) {
- if (s.getName().equalsIgnoreCase(value)) {
- this.setSatellite(s);
- break;
- }
- }
+ this.setSatellite((Satellite) value);
} else {
throw new AdapterParameterDoesNotExistException("Paramater "
+ parameter
diff --git a/core/src/main/java/org/videolan/vlma/common/adapter/DVBTAdapter.java b/core/src/main/java/org/videolan/vlma/common/adapter/DVBTAdapter.java
index c235e99..7ae42e9 100644
--- a/core/src/main/java/org/videolan/vlma/common/adapter/DVBTAdapter.java
+++ b/core/src/main/java/org/videolan/vlma/common/adapter/DVBTAdapter.java
@@ -20,7 +20,6 @@
package org.videolan.vlma.common.adapter;
-import org.videolan.vlma.common.Data;
import org.videolan.vlma.common.exception.AdapterParameterDoesNotExistException;
import org.videolan.vlma.common.media.Media;
import org.videolan.vlma.common.media.TNTChannel;
@@ -42,7 +41,7 @@ public class DVBTAdapter extends AbstractAdapter {
return "DVB-T";
}
- public void setParameter(String parameter, String value, Data data)
+ public void setParameter(String parameter, Object value)
throws AdapterParameterDoesNotExistException {
{
throw new AdapterParameterDoesNotExistException("Parameter "
diff --git a/core/src/main/java/org/videolan/vlma/common/adapter/FilesAdapter.java b/core/src/main/java/org/videolan/vlma/common/adapter/FilesAdapter.java
index e6199e3..6ef7c60 100644
--- a/core/src/main/java/org/videolan/vlma/common/adapter/FilesAdapter.java
+++ b/core/src/main/java/org/videolan/vlma/common/adapter/FilesAdapter.java
@@ -20,7 +20,6 @@
package org.videolan.vlma.common.adapter;
-import org.videolan.vlma.common.Data;
import org.videolan.vlma.common.exception.AdapterParameterDoesNotExistException;
import org.videolan.vlma.common.media.FilesChannel;
import org.videolan.vlma.common.media.Media;
@@ -43,7 +42,7 @@ public class FilesAdapter extends AbstractAdapter {
return "Files-Adapter";
}
- public void setParameter(String parameter, String value, Data data)
+ public void setParameter(String parameter, Object value)
throws AdapterParameterDoesNotExistException {
{
throw new AdapterParameterDoesNotExistException("Le paramètre "
diff --git a/core/src/test/java/org/videolan/vlma/common/DataMockImpl.java b/core/src/test/java/org/videolan/vlma/common/DataMockImpl.java
index 22287c7..a3d7126 100644
--- a/core/src/test/java/org/videolan/vlma/common/DataMockImpl.java
+++ b/core/src/test/java/org/videolan/vlma/common/DataMockImpl.java
@@ -180,7 +180,7 @@ public class DataMockImpl implements Data {
}
public void setAdapterParameter(int server, String name, String parameter,
- String value) throws AdapterDoesNotExistException,
+ Object value) throws AdapterDoesNotExistException,
AdapterParameterDoesNotExistException {
}
diff --git a/daemon/src/main/java/org/videolan/vlma/daemon/DataImpl.java b/daemon/src/main/java/org/videolan/vlma/daemon/DataImpl.java
index 1c76ed1..d2fd527 100644
--- a/daemon/src/main/java/org/videolan/vlma/daemon/DataImpl.java
+++ b/daemon/src/main/java/org/videolan/vlma/daemon/DataImpl.java
@@ -326,7 +326,7 @@ public class DataImpl implements Data {
}
synchronized public void setAdapterParameter(int server, String name,
- String parameter, String value)
+ String parameter, Object value)
throws AdapterDoesNotExistException, AdapterParameterDoesNotExistException {
Server s = this.getServer(server);
Map m = s.getAdapters();
@@ -334,7 +334,7 @@ public class DataImpl implements Data {
if (a == null) {
throw new AdapterDoesNotExistException("Adapter " + name + " doesn't exist in server " + server + ".");
}
- a.setParameter(parameter, value, this);
+ a.setParameter(parameter, value);
}
@SuppressWarnings("unchecked")
diff --git a/web/src/main/java/org/videolan/vlma/web/server/ServersAdapterAddController.java b/web/src/main/java/org/videolan/vlma/web/server/ServersAdapterAddController.java
index 1099c6e..0646f36 100644
--- a/web/src/main/java/org/videolan/vlma/web/server/ServersAdapterAddController.java
+++ b/web/src/main/java/org/videolan/vlma/web/server/ServersAdapterAddController.java
@@ -34,6 +34,7 @@ import org.videolan.vlma.common.Data;
import org.videolan.vlma.common.server.Server;
import org.videolan.vlma.common.adapter.Adapter;
import org.videolan.vlma.common.adapter.DVBSAdapter;
+import org.videolan.vlma.common.media.Satellite;
public class ServersAdapterAddController extends SimpleFormController {
@@ -56,9 +57,13 @@ public class ServersAdapterAddController extends SimpleFormController {
String type = ((ServersAdapterAdd) command).getType();
data.addAdapter(server, adapterName, type);
Adapter a = data.getAdapter(server, adapterName);
+ String satelliteName = ((ServersAdapterAdd) command).getSatellite().toUpperCase();
if (a.getClass().equals(DVBSAdapter.class)) {
- data.setAdapterParameter(server, adapterName, "satellite",
- ((ServersAdapterAdd) command).getSatellite().toUpperCase());
+ for (Satellite s : data.getSatellites()) {
+ if (s.getName().equalsIgnoreCase(satelliteName)) {
+ data.setAdapterParameter(server, adapterName, "satellite", s);
+ }
+ }
}
ModelAndView mav = new ModelAndView();
mav.addObject("server", data.getServer(server));
More information about the vlma-devel
mailing list