diff options
| author | guest <guest@f059d3a0-6783-47b7-97ff-1fe0bbf25129> | 2008-09-29 17:27:17 +0000 |
|---|---|---|
| committer | guest <guest@f059d3a0-6783-47b7-97ff-1fe0bbf25129> | 2008-09-29 17:27:17 +0000 |
| commit | 408445cc49f360b979266ea93cf3bcb25a50a8e4 (patch) | |
| tree | f04ddd775d23205e603f552693e448600b9b937d /src/YalpInputs/YalpPGSqlInput/YalpInputPluginImpl.java | |
| parent | 1124d590a9db28e5a4088f8e84557469e7ee4bb2 (diff) | |
fixed crash introtuced in last commit
git-svn-id: http://manut.eu/svn/yalp/trunk@7 f059d3a0-6783-47b7-97ff-1fe0bbf25129
Diffstat (limited to 'src/YalpInputs/YalpPGSqlInput/YalpInputPluginImpl.java')
| -rw-r--r-- | src/YalpInputs/YalpPGSqlInput/YalpInputPluginImpl.java | 87 |
1 files changed, 65 insertions, 22 deletions
diff --git a/src/YalpInputs/YalpPGSqlInput/YalpInputPluginImpl.java b/src/YalpInputs/YalpPGSqlInput/YalpInputPluginImpl.java index 573c587..ef18b31 100644 --- a/src/YalpInputs/YalpPGSqlInput/YalpInputPluginImpl.java +++ b/src/YalpInputs/YalpPGSqlInput/YalpInputPluginImpl.java @@ -38,6 +38,12 @@ public class YalpInputPluginImpl extends InputPluginInterfacePOA { logger.debug("YalpInputPluginImpl()"); } + public void setInfo(PluginInfo info) + { + logger.debug("interfaceImpl - setInfo(): "+info.id); + pluginInfo = info; + } + public void setORB(ORB _orb) { orb = _orb; @@ -88,6 +94,13 @@ public class YalpInputPluginImpl extends InputPluginInterfacePOA { logger.debug("search("+str+")"); + YalpError error = new YalpError(); + error.descr = ""; + error.msg = ""; + error.level = YalpErrorLevel.ERROR_LEVEL_INFO; + error.code = YalpErrorCode.OK; + err.value = error; + ArrayList <String> searchWords = stringCut(str); String query = new String(); Boolean first, doIntersect, sound, video, image; @@ -112,7 +125,6 @@ public class YalpInputPluginImpl extends InputPluginInterfacePOA { } } - //for( int i = 0; i < searchWords.size(); i++ ) { for( String pattern : searchWords ) { first = true; @@ -162,42 +174,73 @@ public class YalpInputPluginImpl extends InputPluginInterfacePOA { logger.debug("sending SQL request: "+query); + ArrayList<Media> foundMedias = new ArrayList<Media>(); + try { Statement stat = con.createStatement(); ResultSet sqlResult = stat.executeQuery(query); System.out.println("found: "); + MediaType type; + while( sqlResult.next() ) { System.out.print(sqlResult.getString(3)+": "); System.out.print(sqlResult.getString(4)+"\t| "); System.out.println(sqlResult.getString(6)); - /* - result.add( - new Result( sqlResult.getInt(1), - sqlResult.getString(2), - ---> - result.getString(3), - result.getString(4), - result.getString(5), - result.getString(6), - result.getString(7), - result.getString(8), - result.getInt(9), - result.getInt(10), - result.getString(11), - result.getInt(12), - result.getString(13), - result.getString(14), - result.getString(15) ) ); - */ - } - System.out.println(); + switch( sqlResult.getString(2).charAt(0) ) { + case 's': + type = MediaType.SOUND; + break; + case 'v': + type = MediaType.VIDEO; + break; + case 'i': + type = MediaType.IMAGE; + break; + default: + type = MediaType.OTHER; + } + + StringProperty[] strProp = new StringProperty[1]; + strProp[0] = new StringProperty("",""); + + IntProperty[] intProp = new IntProperty[1]; + intProp[0] = new IntProperty("", 0); + + String[] tags = new String[1]; + tags[0] = "blubb"; + + YalpUser owner = new YalpUser( 0, // user id + "huhu", // name + "manut", // real name + AccessRights.ADMIN ); + + Media newMedia = new Media( sqlResult.getString(6), + sqlResult.getInt(1), + type, + pluginInfo.id, + owner, + "", // last edit + sqlResult.getString(3), + sqlResult.getString(4), + sqlResult.getString(5), + strProp, + intProp, + tags ); + + foundMedias.add(newMedia); + logger.debug( sqlResult.getString(6) + "added to foundMedias"); + } } catch( SQLException e ) { System.out.println("Exception in PGSqlInput.search: "+e); } + Media[] m = new Media[foundMedias.size()]; + result.value = foundMedias.toArray(m); + + logger.debug("psql search done"); } // == REIMPLEMENTATION NEEDED : == // |
