From: Vásáry Dániel Date: Tue, 10 Oct 2017 13:06:05 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=c086a7da5f42fd82c57183f37044fcb49fc0fb93;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30577 --- diff --git a/client/DxPlay/DxPlayer.cs b/client/DxPlay/DxPlayer.cs index d8dff3b1..17443089 100644 --- a/client/DxPlay/DxPlayer.cs +++ b/client/DxPlay/DxPlayer.cs @@ -254,8 +254,13 @@ namespace DxPlay { hr = m_FilterGraph.AddFilter(m_videoRenderer, "Video Mixing Renderer 9"); DsError.ThrowExceptionForHR(hr); + IVMRDeinterlaceControl9 deinterlace = (IVMRDeinterlaceControl9)m_videoRenderer; + Guid interlaceMode; + deinterlace.GetActualDeinterlaceMode(0, out interlaceMode); + FilterGraphTools.ConnectFilters(graphBuilder, sampGrabber, "Output", m_videoRenderer, "VMR Input0", true); + ConfigureVideoWindow(hWin); if (DsFindPin.ByName(splitter, "Audio") != null) { diff --git a/client/Maestro/Maestro.csproj b/client/Maestro/Maestro.csproj index 48484cd1..272ea5da 100644 --- a/client/Maestro/Maestro.csproj +++ b/client/Maestro/Maestro.csproj @@ -271,9 +271,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest diff --git a/client/Maestro/Resources/configuration-fxp-isilon.json b/client/Maestro/Resources/configuration-fxp-isilon.json index c5da3590..dbd4e0c1 100644 --- a/client/Maestro/Resources/configuration-fxp-isilon.json +++ b/client/Maestro/Resources/configuration-fxp-isilon.json @@ -23,7 +23,7 @@ { "$type": "OctopusMetadata", "server": { - "address": "http://10.10.1.28:8080/services/rest/octopus", + "address": "http://10.10.1.28/services/rest/octopus", "userName": "dani", "password": "dani", "timeout": 1000 @@ -41,7 +41,7 @@ { "$type": "MediaCubeMetadata", "server": { - "address": "http://10.10.1.28:8080/services/rest/jobengine", + "address": "http://10.10.1.28/services/rest/jobengine", "userName": "dani", "password": "dani" } diff --git a/client/Maestro/Resources/configuration-fxp.json b/client/Maestro/Resources/configuration-fxp.json index 6077a557..192109ac 100644 --- a/client/Maestro/Resources/configuration-fxp.json +++ b/client/Maestro/Resources/configuration-fxp.json @@ -23,7 +23,7 @@ { "$type": "OctopusMetadata", "server": { - "address": "http://10.10.1.28:8080/services/rest/octopus", + "address": "http://10.10.1.28/services/rest/octopus", "userName": "dani", "password": "dani", "timeout": 1000 @@ -41,7 +41,7 @@ { "$type": "MediaCubeMetadata", "server": { - "address": "http://10.10.1.28:8080/services/rest/jobengine", + "address": "http://10.10.1.28/services/rest/jobengine", "userName": "dani", "password": "dani" } diff --git a/client/Maestro/Resources/configuration-ingest - Copy.json b/client/Maestro/Resources/configuration-ingest - Copy.json deleted file mode 100644 index d382eb31..00000000 --- a/client/Maestro/Resources/configuration-ingest - Copy.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "title": "Betöltés", - "active": true, - "startInTray": false, - "enableCustomMetadataId": false, - "player": { - "enabled": true, - "autoStart": false, - "segmentEditor": false - }, - "source": { - "$type": "UNCSource", - "local": { - "address": "file://c:\\_video\\v\\sxs\\xdroot\\clip" - } - }, - "metadatas": [ - { - "$type": "OctopusMetadata", - "server": { - "address": "http://10.10.1.28:8080/services/rest/octopus/", - "userName": "user", - "password": "password", - "timeout": 1000 - } - }, - { - "$type": "TrafficMetadata", - "server": { - "address": "Data Source=10.10.1.45\\sql16;Initial Catalog=PA_Echo;Persist Security Info=True;", - "userName": "MAM", - "password": "Echotv.hu", - "timeout": 5 - } - }, - { - "$type": "MediaCubeMetadata", - "server": { - "address": "http://10.10.1.28:8080/services/rest/jobengine/", - "userName": "user", - "password": "password", - "timeout": 1000 - } - } - ], - "targets": [ - { - "label": "Híranyag betöltés", - "processor": "UNCTargetProcessor", - "outputFormat": "%ID%-%SOURCENAME%", - "tag": "Betöltés", - "createSubFolder": true, - "killDateDays": 7, - "useMetadata": false, - "remote": { - "address": "file://10.10.1.100/BRAAVOS/ARCHIVE", - "userName": "mediacube", - "password": "Broadca5T" - } - }, - { - "label": "Adásanyag betöltés", - "processor": "UNCTargetProcessor", - "outputFormat": "%ID%", - "tag": "Betöltés", - "saveSegments": false, - "killDateDays": 7, - "createSubFolder": false, - "useMetadata": false, - "remote": { - "address": "file://10.10.1.100/BRAAVOS/PLAYOUT_CHECK", - "userName": "mediacube", - "password": "Broadca5T" - } - } - ] -} diff --git a/client/Maestro/Resources/configuration-ingest.json b/client/Maestro/Resources/configuration-ingest.json index afef4029..2a2d3a31 100644 --- a/client/Maestro/Resources/configuration-ingest.json +++ b/client/Maestro/Resources/configuration-ingest.json @@ -19,7 +19,7 @@ { "$type": "OctopusMetadata", "server": { - "address": "http://10.10.1.28:8080/services/rest/octopus/", + "address": "http://10.10.1.28/services/rest/octopus/", "userName": "user", "password": "password", "timeout": 1000 @@ -37,7 +37,7 @@ { "$type": "MediaCubeMetadata", "server": { - "address": "http://10.10.1.28:8080/services/rest/jobengine/", + "address": "http://10.10.1.28/services/rest/jobengine/", "userName": "user", "password": "password", "timeout": 1000 diff --git a/client/Maestro/Resources/configuration-nexio.json b/client/Maestro/Resources/configuration-nexio.json index f0a69cb4..e6a989ec 100644 --- a/client/Maestro/Resources/configuration-nexio.json +++ b/client/Maestro/Resources/configuration-nexio.json @@ -24,7 +24,7 @@ { "$type": "OctopusMetadata", "server": { - "address": "http://10.10.1.28:8080/services/rest/octopus", + "address": "http://10.10.1.28/services/rest/octopus", "userName": "dani", "password": "dani", "timeout": 1000 @@ -42,7 +42,7 @@ { "$type": "MediaCubeMetadata", "server": { - "address": "http://10.10.1.28:8080/services/rest/jobengine", + "address": "http://10.10.1.28/services/rest/jobengine", "userName": "dani", "password": "dani" } diff --git a/client/Maestro/Resources/configuration-unc.json b/client/Maestro/Resources/configuration-unc.json index f9c9112f..1a1505e2 100644 --- a/client/Maestro/Resources/configuration-unc.json +++ b/client/Maestro/Resources/configuration-unc.json @@ -23,7 +23,7 @@ { "$type": "OctopusMetadata", "server": { - "address": "http://10.10.1.28:8080/services/rest/octopus/", + "address": "http://10.10.1.28/services/rest/octopus/", "userName": "dani", "password": "dani", "timeout": 1000 @@ -41,7 +41,7 @@ { "$type": "MediaCubeMetadata", "server": { - "address": "http://10.10.1.28:8080/services/rest/jobengine/", + "address": "http://10.10.1.28/services/rest/jobengine/", "userName": "dani", "password": "dani" } diff --git a/server/-configuration/jetty-deploy/etc/jetty.xml b/server/-configuration/jetty-deploy/etc/jetty.xml new file mode 100644 index 00000000..f85a955c --- /dev/null +++ b/server/-configuration/jetty-deploy/etc/jetty.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server/-configuration/jetty-deploy/etc/keystore b/server/-configuration/jetty-deploy/etc/keystore new file mode 100644 index 00000000..95d7f4c7 Binary files /dev/null and b/server/-configuration/jetty-deploy/etc/keystore differ diff --git a/server/-configuration/jetty-deploy/etc/localhost.jks b/server/-configuration/jetty-deploy/etc/localhost.jks new file mode 100644 index 00000000..95d7f4c7 Binary files /dev/null and b/server/-configuration/jetty-deploy/etc/localhost.jks differ diff --git a/server/-configuration/jetty-deploy/etc/login.conf b/server/-configuration/jetty-deploy/etc/login.conf new file mode 100644 index 00000000..7f38fa8f --- /dev/null +++ b/server/-configuration/jetty-deploy/etc/login.conf @@ -0,0 +1,5 @@ +loginModule { + user.jobengine.osgi.service.LoginModule required + debug="true" + option="1"; +}; \ No newline at end of file diff --git a/server/-configuration/jetty-deploy/etc/login.properties b/server/-configuration/jetty-deploy/etc/login.properties new file mode 100644 index 00000000..4b91dd7b --- /dev/null +++ b/server/-configuration/jetty-deploy/etc/login.properties @@ -0,0 +1,4 @@ +me=me,me,roleA +lol=lol,user,admin +password=password,user,admin +user=user,user,admin diff --git a/server/-configuration/jetty-deploy/etc/login_propertyfile.conf b/server/-configuration/jetty-deploy/etc/login_propertyfile.conf new file mode 100644 index 00000000..3829c9b1 --- /dev/null +++ b/server/-configuration/jetty-deploy/etc/login_propertyfile.conf @@ -0,0 +1,5 @@ +loginModule { +org.eclipse.jetty.plus.jaas.spi.PropertyFileLoginModule required +debug="true" +file="/etc/login.properties"; +}; \ No newline at end of file diff --git a/server/-configuration/jetty-deploy/etc/sampkey.jks b/server/-configuration/jetty-deploy/etc/sampkey.jks new file mode 100644 index 00000000..e8da3a67 Binary files /dev/null and b/server/-configuration/jetty-deploy/etc/sampkey.jks differ diff --git a/server/-configuration/jetty-deploy/etc/user-jetty-deployer.xml b/server/-configuration/jetty-deploy/etc/user-jetty-deployer.xml new file mode 100644 index 00000000..ba61d105 --- /dev/null +++ b/server/-configuration/jetty-deploy/etc/user-jetty-deployer.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern + .*/[^/]*servlet-api-[^/]*\.jar$|.*/javax.servlet.jsp.jstl-.*\.jar$|.*/org.apache.taglibs.taglibs-standard-impl-.*\.jar$ + + + + + + + + + + + jetty.deploy.monitoredPath + + / + + + + + + jetty.deploy.defaultsDescriptorPath + + /etc/webdefault.xml + + + + + + + + + + + + + + + + + + diff --git a/server/-configuration/jetty-deploy/etc/user-jetty-http-redirect.xml b/server/-configuration/jetty-deploy/etc/user-jetty-http-redirect.xml new file mode 100644 index 00000000..701042ca --- /dev/null +++ b/server/-configuration/jetty-deploy/etc/user-jetty-http-redirect.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + https + 8443 + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server/-configuration/jetty-deploy/etc/user-jetty-http.xml b/server/-configuration/jetty-deploy/etc/user-jetty-http.xml new file mode 100644 index 00000000..319ae6cb --- /dev/null +++ b/server/-configuration/jetty-deploy/etc/user-jetty-http.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server/-configuration/jetty-deploy/etc/user-jetty-https.xml b/server/-configuration/jetty-deploy/etc/user-jetty-https.xml new file mode 100644 index 00000000..71a08377 --- /dev/null +++ b/server/-configuration/jetty-deploy/etc/user-jetty-https.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + http/1.1 + + + + + + + + + + + + + + + diff --git a/server/-configuration/jetty-deploy/etc/user-jetty-ssl-context.xml b/server/-configuration/jetty-deploy/etc/user-jetty-ssl-context.xml new file mode 100644 index 00000000..26309180 --- /dev/null +++ b/server/-configuration/jetty-deploy/etc/user-jetty-ssl-context.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + / + + + + + / + + + + + + + + + + diff --git a/server/-configuration/jetty-deploy/etc/user-jetty-ssl.xml b/server/-configuration/jetty-deploy/etc/user-jetty-ssl.xml new file mode 100644 index 00000000..365ea983 --- /dev/null +++ b/server/-configuration/jetty-deploy/etc/user-jetty-ssl.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server/-configuration/jetty-deploy/etc/user-jetty.xml b/server/-configuration/jetty-deploy/etc/user-jetty.xml new file mode 100644 index 00000000..0ba38381 --- /dev/null +++ b/server/-configuration/jetty-deploy/etc/user-jetty.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5000 + + + + diff --git a/server/-configuration/jetty-deploy/etc/webdefault.xml b/server/-configuration/jetty-deploy/etc/webdefault.xml new file mode 100644 index 00000000..d54d76f3 --- /dev/null +++ b/server/-configuration/jetty-deploy/etc/webdefault.xml @@ -0,0 +1,534 @@ + + + + + + + + + + + + + + + + + + + + + + + Default web.xml file. + This file is applied to a Web application before it's own WEB_INF/web.xml file + + + + + + + + org.eclipse.jetty.servlet.listener.ELContextCleaner + + + + + + + + org.eclipse.jetty.servlet.listener.IntrospectorCleaner + + + + + + + + + + + + + + + + + default + org.eclipse.jetty.servlet.DefaultServlet + + aliases + false + + + acceptRanges + true + + + dirAllowed + true + + + welcomeServlets + false + + + redirectWelcome + false + + + maxCacheSize + 256000000 + + + maxCachedFileSize + 200000000 + + + maxCachedFiles + 2048 + + + gzip + false + + + etags + false + + + useFileMappedBuffer + true + + + + 0 + + + + default + / + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jsp + org.eclipse.jetty.jsp.JettyJspServlet + + logVerbosityLevel + DEBUG + + + fork + false + + + xpoweredBy + false + + + compilerTargetVM + 1.7 + + + compilerSourceVM + 1.7 + + + 0 + + + + jsp + *.jsp + *.jspf + *.jspx + *.xsp + *.JSP + *.JSPF + *.JSPX + *.XSP + + + + + + + + 30 + + + + + + + + + + + + + + + index.html + index.htm + index.jsp + + + + + + + + ar + ISO-8859-6 + + + be + ISO-8859-5 + + + bg + ISO-8859-5 + + + ca + ISO-8859-1 + + + cs + ISO-8859-2 + + + da + ISO-8859-1 + + + de + ISO-8859-1 + + + el + ISO-8859-7 + + + en + ISO-8859-1 + + + es + ISO-8859-1 + + + et + ISO-8859-1 + + + fi + ISO-8859-1 + + + fr + ISO-8859-1 + + + hr + ISO-8859-2 + + + hu + ISO-8859-2 + + + is + ISO-8859-1 + + + it + ISO-8859-1 + + + iw + ISO-8859-8 + + + ja + Shift_JIS + + + ko + EUC-KR + + + lt + ISO-8859-2 + + + lv + ISO-8859-2 + + + mk + ISO-8859-5 + + + nl + ISO-8859-1 + + + no + ISO-8859-1 + + + pl + ISO-8859-2 + + + pt + ISO-8859-1 + + + ro + ISO-8859-2 + + + ru + ISO-8859-5 + + + sh + ISO-8859-5 + + + sk + ISO-8859-2 + + + sl + ISO-8859-2 + + + sq + ISO-8859-2 + + + sr + ISO-8859-5 + + + sv + ISO-8859-1 + + + tr + ISO-8859-9 + + + uk + ISO-8859-5 + + + zh + GB2312 + + + zh_TW + Big5 + + + + + + + + + Disable TRACE + / + TRACE + + + + + + Enable everything but TRACE + / + TRACE + + + + + diff --git a/server/-configuration/stop-mediacube.sh b/server/-configuration/stop-mediacube.sh index d7f1a895..1c31a318 100644 --- a/server/-configuration/stop-mediacube.sh +++ b/server/-configuration/stop-mediacube.sh @@ -1,3 +1,3 @@ -wget -qO- http://localhost:8080/services/rest/jobengine/halt +wget -qO- http://localhost/services/rest/jobengine/halt exit 0 diff --git a/server/-product/mediacube.product b/server/-product/mediacube.product index a06024d9..6c6422cf 100644 --- a/server/-product/mediacube.product +++ b/server/-product/mediacube.product @@ -9,21 +9,21 @@ -consoleLog -console 5555 - -Dfile.encoding=UTF-8 --agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8888 --Djavax.ws.rs.ext.RuntimeDelegate=org.jboss.resteasy.spi.ResteasyProviderFactory - -#System --Dorg.eclipse.equinox.http.jetty.http.port=8080 --Dorg.eclipse.epp.logging.aeri.skipReports=true --Declipse.ignoreApp=true --Dosgi.noShutdown=true --Djetty.home=./configuration/jetty --Djetty.etc.config.urls=etc/user-jetty.xml,etc/user-jetty-ssl.xml,etc/user-jetty-ssl-context.xml,etc/user-jetty-http.xml,etc/user-jetty-https.xml --Dlog4j.configurationFile=./configuration/log4j2.xml --Djobengine.loglevel=INFO --Djobengine.jobsteps.root=./configuration/executors --Djobengine.jobtemplates.root=./configuration/jobtemplates + -Dfile.encoding=UTF-8 +-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8888 +-Djavax.ws.rs.ext.RuntimeDelegate=org.jboss.resteasy.spi.ResteasyProviderFactory + +#System +-Dorg.eclipse.equinox.http.jetty.http.port=80 +-Dorg.eclipse.epp.logging.aeri.skipReports=true +-Declipse.ignoreApp=true +-Dosgi.noShutdown=true +-Djetty.home=./configuration/jetty +-Djetty.etc.config.urls=etc/user-jetty.xml,etc/user-jetty-ssl.xml,etc/user-jetty-ssl-context.xml,etc/user-jetty-http.xml,etc/user-jetty-https.xml +-Dlog4j.configurationFile=./configuration/log4j2.xml +-Djobengine.loglevel=INFO +-Djobengine.jobsteps.root=./configuration/executors +-Djobengine.jobtemplates.root=./configuration/jobtemplates -Djobengine.jobscheduling.config=./configuration/scheduledjobs.json #Database diff --git a/server/-product/pom.xml b/server/-product/pom.xml index 6e4635a0..1cc362ae 100644 --- a/server/-product/pom.xml +++ b/server/-product/pom.xml @@ -196,7 +196,7 @@ ${project.build.directory}/products/MediaCube/win32/win32/x86_64/configuration/jetty/etc - ${basedir}/../-configuration/jetty/etc + ${basedir}/../-configuration/jetty-deploy/etc @@ -211,7 +211,7 @@ ${project.build.directory}/products/MediaCube/linux/gtk/x86_64/configuration/jetty/etc - ${basedir}/../-configuration/jetty/etc + ${basedir}/../-configuration/jetty-deploy/etc diff --git a/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java b/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java index 58d13a5d..503e5e2c 100644 --- a/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java +++ b/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java @@ -31,11 +31,9 @@ import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; -import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetHeaders; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeMessage.RecipientType; import javax.mail.internet.MimeMultipart; import javax.mail.internet.MimeUtility; import javax.mail.util.ByteArrayDataSource; @@ -299,7 +297,7 @@ public class SmtpManager extends AbstractManager { try { if (appendEvent.getMarker() instanceof MediaCubeMarker) { MediaCubeMarker mcm = (MediaCubeMarker) appendEvent.getMarker(); - message.setRecipient(RecipientType.TO, new InternetAddress(mcm.getTo())); + //message.setRecipient(RecipientType.TO, new InternetAddress(mcm.getTo())); } final LogEvent[] priorEvents = buffer.removeAll(); diff --git a/server/user.jobengine.osgi.db/database/structure.sql b/server/user.jobengine.osgi.db/database/structure.sql index e29e6603..3a1e2f47 100644 --- a/server/user.jobengine.osgi.db/database/structure.sql +++ b/server/user.jobengine.osgi.db/database/structure.sql @@ -1,3 +1,7 @@ + +ALTER TABLE ITEM ALTER COLUMN DESCRIPTION SET DATA TYPE VARCHAR(5000) +ALTER TABLE MEDIA ALTER COLUMN DESCRIPTION SET DATA TYPE VARCHAR(5000) + ALTER TABLE MEDIA ALTER COLUMN DESCRIPTION DROP NOT NULL ALTER TABLE ITEM ALTER COLUMN DESCRIPTION DROP NOT NULL diff --git a/server/user.jobengine.osgi.db/src/user/jobengine/db/ItemDAOEx.java b/server/user.jobengine.osgi.db/src/user/jobengine/db/ItemDAOEx.java index a9414c6e..d2015e5d 100644 --- a/server/user.jobengine.osgi.db/src/user/jobengine/db/ItemDAOEx.java +++ b/server/user.jobengine.osgi.db/src/user/jobengine/db/ItemDAOEx.java @@ -21,96 +21,86 @@ public class ItemDAOEx { this.manager = manager; } - public SearchResult search(String criteria, int fromResult, int toResult) { - SearchResult result = new SearchResult(); + private String buildQueryCore(QueryObject parameter) { + QueryBuilder queryBuilder = new QueryBuilder(); + queryBuilder.getParameters(parameter.getFilters()); + return queryBuilder.getQuery(); + } - ResultSet rs = null; - PreparedStatement st = null; - DefaultContext context = manager.getDbContext(); - Connection connection = context.getConnection(); + private String buildResultQuery(QueryObject queryObject, String innerQuery, SearchResult csr) { + StringBuilder resultQuery = new StringBuilder(); + Formatter qf = new Formatter(resultQuery, Locale.getDefault()); + RenderParameter rp = queryObject.getParameters(); + if (rp != null) { + long bottom = rp.getPage() * rp.getRowPerPage() + 1; + long top = bottom + rp.getRowPerPage() - 1; + resultQuery.append("WITH NUMBEREDITEM AS ("); + Metadata orderMetadata = rp.getOrderBy(); + if (queryObject.hasOrderInfo()) + qf.format("SELECT ROWNUMBER() OVER (ORDER BY %1$s %2$s) AS RN, ", orderMetadata.getOrderName("i", "md"), rp.getOrderDirection().name()); + else + resultQuery.append("SELECT ROWNUMBER() OVER () AS RN, "); + resultQuery.append("i.ID, i.TITLE, i.DESCRIPTION, i.ITEMTYPEID, i.HOUSEID, i.CREATED, i.ISFOLDER FROM ITEM i "); + String orderTableName = orderMetadata.getTableName(); + if (orderTableName != null) + qf.format("LEFT OUTER JOIN %1$s md ON (md.ID = i.ID) ", orderTableName); + resultQuery.append("WHERE i.ID IN "); + qf.format("(SELECT ii.ID %1$s AND ii.ITEMTYPEID = %2$d))", innerQuery, csr.getItemType().getId()); + qf.format(" SELECT * FROM NUMBEREDITEM WHERE RN BETWEEN %1$d AND %2$d", bottom, top); + } else { + resultQuery.append("SELECT i.ID, i.TITLE, i.DESCRIPTION, i.ITEMTYPEID, i.HOUSEID, i.CREATED, i.ISFOLDER FROM ITEM i "); + resultQuery.append("WHERE i.ID IN "); + qf.format("(SELECT ii.ID %1$s) ORDER BY i.TITLE", innerQuery); + } - try { - StringBuffer sql = new StringBuffer(); - sql.append("select * from (("); - sql.append( - "select distinct i.id,i.itemtypeid,i.houseid,i.title,i.description,i.isfolder,i.created,i.modified from item i, media m, mediafile mf"); - sql.append( - " where ((CONTAINS(i.title, ?) >= 1) OR (CONTAINS(i.description, ?) >= 1)) and m.itemid = i.id and mf.MEDIAID = m.id"); - sql.append(")UNION("); - sql.append( - "select distinct i2.id,i2.itemtypeid,i2.houseid,i2.title,i2.description,i2.isfolder,i2.created,i2.modified from item i2, media m2, mediafile mf2"); - sql.append( - " where ((CONTAINS(m2.title, ?) >= 1) OR (CONTAINS(m2.description, ?) >= 1)) and m2.itemid = i2.id and mf2.MEDIAID = m2.id"); - sql.append(")UNION("); - sql.append( - "select distinct i3.id,i3.itemtypeid,i3.houseid,i3.title,i3.description,i3.isfolder,i3.created,i3.modified from item i3, media m3, mediafile mf3"); - sql.append(" where (CONTAINS(mf3.relativepath, ?) >= 1) and m3.itemid = i3.id and mf3.MEDIAID = m3.id"); - sql.append(")) order by title"); - String query = sql.toString(); - /* - query = "SELECT i.* from item i, media m, mediafile mf WHERE m.ITEMID = i.id AND mf.MEDIAID = m.ID" - + " AND (" + "(CONTAINS(i.TITLE, '" + criteria + "') >= 1) OR (CONTAINS(i.DESCRIPTION, '" + criteria - + "') >= 1)" + " OR (CONTAINS(m.TITLE, '" + criteria + "') >= 1) OR (CONTAINS(m.DESCRIPTION, '" - + criteria + "') >= 1)" + " OR (CONTAINS(mf.RELATIVEPATH, '" + criteria - + "') >= 1)) ORDER BY i.title"; - */ - // query = "SELECT * FROM ITEM ORDER BY title"; + logger.info(resultQuery.toString()); + return resultQuery.toString(); + } - st = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); - for (int s = 1; s <= 5; s++) { - st.setString(s, criteria); - } - rs = st.executeQuery(); - rs.last(); - result.setItemCount(rs.getRow()); + private List getResultHeaders(Connection connection, QueryObject queryObject, String innerQuery) { + List results = new ArrayList(); + String typeQuery; + if (queryObject.getParameters() == null) + typeQuery = String.format("SELECT CAST(COUNT(DISTINCT(ii.ID)) AS BIGINT) %s", innerQuery); + else + typeQuery = String.format("SELECT ii.ITEMTYPEID, CAST(COUNT(DISTINCT(ii.ID)) AS BIGINT) %s GROUP BY ii.ITEMTYPEID", innerQuery); - // set begining position - if (fromResult > -1) { - if (fromResult <= result.getItemCount()) { - if (fromResult > 1) { - rs.absolute(fromResult - 1); - } else { - rs.beforeFirst(); - } + logger.info(typeQuery.toString()); + PreparedStatement st = null; + ResultSet rs = null; + try { + st = connection.prepareStatement(typeQuery); + rs = st.executeQuery(); + while (rs.next()) { + SearchResult sr = new SearchResult(); + if (queryObject.getParameters() == null) { + sr.setItemCount(rs.getLong(1)); } else { - if (result.getItemCount() > 0) { - throw new Exception("Invalid searchResult 'from' position: " + fromResult + " total records: " - + result.getItemCount() + " " + query); - } + ItemType itemType = (ItemType) manager.get(ItemType.class, rs.getLong(1)); + sr.setItemType(itemType); + sr.setItemCount(rs.getLong(2)); } - } else { - rs.beforeFirst(); - } - int maxRecords = toResult - fromResult; - - ItemDAO dao = (ItemDAO) manager.getBaseDAO(Item.class); - result.setItems((List) (List) dao.entities(context, rs, maxRecords)); - - connection.commit(); - } catch (Exception e) { - try { - connection.rollback(); - } catch (Exception e1) { - e1.printStackTrace(); + sr.setParameters(queryObject.getParameters()); + results.add(sr); } - manager.throwError(e); + } catch (Exception e) { + e.printStackTrace(); } finally { try { if (rs != null) rs.close(); } catch (Exception e1) { + e1.printStackTrace(); } try { if (st != null) st.close(); } catch (Exception e1) { + e1.printStackTrace(); } - manager.putDbContext(context); } - manager.traceOut(); - - return result; + return results; } @SuppressWarnings("unchecked") @@ -187,90 +177,91 @@ public class ItemDAOEx { return results; } - private String buildResultQuery(QueryObject queryObject, String innerQuery, SearchResult csr) { - StringBuilder resultQuery = new StringBuilder(); - Formatter qf = new Formatter(resultQuery, Locale.getDefault()); - RenderParameter rp = queryObject.getParameters(); - if (rp != null) { - long bottom = rp.getPage() * rp.getRowPerPage() + 1; - long top = bottom + rp.getRowPerPage() - 1; - resultQuery.append("WITH NUMBEREDITEM AS ("); - Metadata orderMetadata = rp.getOrderBy(); - if (queryObject.hasOrderInfo()) - qf.format("SELECT ROWNUMBER() OVER (ORDER BY %1$s %2$s) AS RN, ", orderMetadata.getOrderName("i", "md"), - rp.getOrderDirection().name()); - else - resultQuery.append("SELECT ROWNUMBER() OVER () AS RN, "); - resultQuery.append( - "i.ID, i.TITLE, i.DESCRIPTION, i.ITEMTYPEID, i.HOUSEID, i.CREATED, i.ISFOLDER FROM ITEM i "); - String orderTableName = orderMetadata.getTableName(); - if (orderTableName != null) - qf.format("LEFT OUTER JOIN %1$s md ON (md.ID = i.ID) ", orderTableName); - resultQuery.append("WHERE i.ID IN "); - qf.format("(SELECT ii.ID %1$s AND ii.ITEMTYPEID = %2$d))", innerQuery, csr.getItemType().getId()); - qf.format(" SELECT * FROM NUMBEREDITEM WHERE RN BETWEEN %1$d AND %2$d", bottom, top); - } else { - resultQuery.append( - "SELECT i.ID, i.TITLE, i.DESCRIPTION, i.ITEMTYPEID, i.HOUSEID, i.CREATED, i.ISFOLDER FROM ITEM i "); - resultQuery.append("WHERE i.ID IN "); - qf.format("(SELECT ii.ID %1$s) ORDER BY i.TITLE", innerQuery); - } - - logger.info(resultQuery.toString()); - return resultQuery.toString(); - } - - private String buildQueryCore(QueryObject parameter) { - QueryBuilder queryBuilder = new QueryBuilder(); - queryBuilder.getParameters(parameter.getFilters()); - return queryBuilder.getQuery(); - } - - private List getResultHeaders(Connection connection, QueryObject queryObject, String innerQuery) { - List results = new ArrayList(); - String typeQuery; - if (queryObject.getParameters() == null) - typeQuery = String.format("SELECT CAST(COUNT(DISTINCT(ii.ID)) AS BIGINT) %s", innerQuery); - else - typeQuery = String.format( - "SELECT ii.ITEMTYPEID, CAST(COUNT(DISTINCT(ii.ID)) AS BIGINT) %s GROUP BY ii.ITEMTYPEID", - innerQuery); + public SearchResult search(String criteria, int fromResult, int toResult) { + SearchResult result = new SearchResult(); - logger.info(typeQuery.toString()); - PreparedStatement st = null; ResultSet rs = null; + PreparedStatement st = null; + DefaultContext context = manager.getDbContext(); + Connection connection = context.getConnection(); + try { - st = connection.prepareStatement(typeQuery); + StringBuffer sql = new StringBuffer(); + sql.append("select * from (("); + sql.append("select distinct i.id,i.itemtypeid,i.houseid,i.title,i.description,i.isfolder,i.created,i.modified from item i, media m, mediafile mf"); + sql.append(" where ((CONTAINS(i.title, ?) >= 1) OR (CONTAINS(i.description, ?) >= 1)) and m.itemid = i.id and mf.MEDIAID = m.id"); + sql.append(")UNION("); + sql.append( + "select distinct i2.id,i2.itemtypeid,i2.houseid,i2.title,i2.description,i2.isfolder,i2.created,i2.modified from item i2, media m2, mediafile mf2"); + sql.append(" where ((CONTAINS(m2.title, ?) >= 1) OR (CONTAINS(m2.description, ?) >= 1)) and m2.itemid = i2.id and mf2.MEDIAID = m2.id"); + sql.append(")UNION("); + sql.append( + "select distinct i3.id,i3.itemtypeid,i3.houseid,i3.title,i3.description,i3.isfolder,i3.created,i3.modified from item i3, media m3, mediafile mf3"); + sql.append(" where (CONTAINS(mf3.houseId, ?) >= 1) and m3.itemid = i3.id and mf3.MEDIAID = m3.id"); + sql.append(")) order by title"); + String query = sql.toString(); + /* + query = "SELECT i.* from item i, media m, mediafile mf WHERE m.ITEMID = i.id AND mf.MEDIAID = m.ID" + + " AND (" + "(CONTAINS(i.TITLE, '" + criteria + "') >= 1) OR (CONTAINS(i.DESCRIPTION, '" + criteria + + "') >= 1)" + " OR (CONTAINS(m.TITLE, '" + criteria + "') >= 1) OR (CONTAINS(m.DESCRIPTION, '" + + criteria + "') >= 1)" + " OR (CONTAINS(mf.HOUSEID, '" + criteria + + "') >= 1)) ORDER BY i.title"; + */ + // query = "SELECT * FROM ITEM ORDER BY title"; + + st = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); + for (int s = 1; s <= 5; s++) { + st.setString(s, criteria); + } rs = st.executeQuery(); - while (rs.next()) { - SearchResult sr = new SearchResult(); - if (queryObject.getParameters() == null) { - sr.setItemCount(rs.getLong(1)); + rs.last(); + result.setItemCount(rs.getRow()); + + // set begining position + if (fromResult > -1) { + if (fromResult <= result.getItemCount()) { + if (fromResult > 1) { + rs.absolute(fromResult - 1); + } else { + rs.beforeFirst(); + } } else { - ItemType itemType = (ItemType) manager.get(ItemType.class, rs.getLong(1)); - sr.setItemType(itemType); - sr.setItemCount(rs.getLong(2)); + if (result.getItemCount() > 0) { + throw new Exception("Invalid searchResult 'from' position: " + fromResult + " total records: " + result.getItemCount() + " " + query); + } } - - sr.setParameters(queryObject.getParameters()); - results.add(sr); + } else { + rs.beforeFirst(); } + + int maxRecords = toResult - fromResult; + + ItemDAO dao = (ItemDAO) manager.getBaseDAO(Item.class); + result.setItems((List) (List) dao.entities(context, rs, maxRecords)); + + connection.commit(); } catch (Exception e) { - e.printStackTrace(); + try { + connection.rollback(); + } catch (Exception e1) { + e1.printStackTrace(); + } + manager.throwError(e); } finally { try { if (rs != null) rs.close(); } catch (Exception e1) { - e1.printStackTrace(); } try { if (st != null) st.close(); } catch (Exception e1) { - e1.printStackTrace(); } + manager.putDbContext(context); } - return results; + manager.traceOut(); + + return result; } }