NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Ext.application({
name:'welcome',
launch:function(){
var states=Ext.create('Ext.data.Store',{
fields:['abbr','name'],
data:[{
"abbr":"1",
"name":"1"
},{
"abbr":"2",
"name":"2"
},{

"abbr":"3",
"name":"3"
}]
});
Ext.create('Ext.panel.Panel', {
renderTo: Ext.getBody(),
width: 1350,
height: 350,
title: 'Movie Advance Search',


layout: 'column',
items: [{
xtype: 'panel',
columnWidth:0.5,
height:200,
border:false,
items:[{
xtype:'textfield',
fieldLabel:'Movie Name:',
margin:'50 0 0 160',
id:'r1'

},{
xtype:'splitter'
},{
xtype:'datefield',
fieldLabel:'Release year:',
margin:'0 0 0 160',
id:'r2'


}],
},{
xtype:'panel',
columnWidth:0.5,
height:200,
border:false,
items:[{
xtype:'textfield',
fieldLabel:'Director Name:',
margin:'50 0 0 140',
id:'r3'

},{
xtype:'splitter'
},{
xtype:'combobox',
fieldLabel:'Language',
margin:'0 0 0 140',
id:'r4',
store:states,
displayField:'name',
valueField:'abbr',
id:'r4'

}]
}],
buttons: [{
text: 'Search',
margin:'0 10 0 100',
handler:function()
{
var title=Ext.getCmp('r1').getValue();
var year=Ext.getCmp('r2').getValue().getFullYear().toString();
var dir=Ext.getCmp('r3').getValue();
var lang=Ext.getCmp('r4').getValue();
console.log(title,year,dir,lang);
store.reload({
params:{
start:0,
limit:itemsPerPage,
title:title,
director:dir,
release_year:year,
language:lang


},
});
}



}, {
text: 'Reset',
margin:'0 530 0 0',
handler:function(){
Ext.getCmp('r1').setValue("");
Ext.getCmp('r2').setValue("");
Ext.getCmp('r3').setValue("");
Ext.getCmp('r4').setValue("");

}



}]



});

var itemsPerPage= 10;


var store = new Ext.data.Store({
storeId: 'invoiceStore',
autoLoad: false,
fields:['description','director','features','film_id','language','rating','release','title'],
pageSize:itemsPerPage,
proxy: {
type: 'ajax',
actionMethods: {
read: 'POST'
},


url: 'http://localhost:8080/Summer_Internship_Backend/fetchServlet',
reader: {
type: 'json',
rootProperty: 'custList',
totalProperty:'totalCount',
title:null,
director:null,
release_year:null,
language:null
}
}

});
store.load({
params:{
start:0,
limit:itemsPerPage
}
});

var grid = Ext.create('Ext.grid.Panel', {
title: 'Movie Grid',
store: store,
id: 'testGrid',
name:'testGrid',
listeners:{
select:function(grid){
Ext.getCmp('editbtn').setDisabled(false);
Ext.getCmp('delbtn').setDisabled(false);
}
},
dockedItems: [{
xtype: 'pagingtoolbar',
store: store, // same store GridPanel is using
dock: 'top',
displayInfo: true,
renderTo: Ext.getElementById('Add1'),
items: [,'-',{
xtype: 'button',
textAlign: 'center',
text: '<span class="x-fa fa-plus-circle fa-lg" style="color:#42a1f5;"></span> Add',
id:'Add1',
listeners: {
click: function() {
win.show();
}
}
},'-',{
xtype: 'button',
textAlign: 'center',
text: '<span class="x-fa fa-edit fa-lg" style="color:#42a1f5;"></span> Edit',
id:'editbtn',
disable:true,
handler: function(){
var data = Ext.getCmp('testGrid').getSelectionModel().getSelection()[0].data;

console.log(data);

Ext.create('Ext.window.Window', {
title: 'Edit Film',
height: 450,
width: 500,
bodyPadding: 5,
layout: 'fit',
items: [{
border: false,
iconCls: 'icon-grid',
animCollapse: false,

xtype: 'form',
header: false,
bodyPadding: 15,
url: 'http://localhost:8080/Summer_Internship_Backend/editServlet',
items: [
{
xtype: 'hiddenfield',
fieldLabel: 'ID',
anchor: '100%',
value: data.film_id,
name: 'film_id'
}
,{
xtype: 'textfield',
fieldLabel: 'Title',
anchor: '100%',
name: 'Title',
value: data.title,
},
{
xtype: 'numberfield',
fieldLabel: 'release_year',
name: 'release_year',
maxValue: 2021,
minValue: 1990,
anchor: '100%',
value: data.release,
},
{
xtype: 'combo',
fieldLabel: 'special_features',
name: 'special_features',
store: Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data: [{
'abbr': 'Trailors',
'name': 'Trailors'
},{
'abbr': 'Deleted Scenes',
'name': 'Deleted Scenes'
},{
'abbr': 'Behind Scenes',
'name': 'Behind Scenes'
}]
}),
displayField: 'name',
valueField: 'abbr',
anchor: '100%',
value: data.features,
},
{
xtype: 'combo',
fieldLabel: 'Rating',
name: 'Rating',
store: Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data: [{
'abbr': 'R',
'name': 'R'
},{
'abbr': 'PG',
'name': 'PG'
},{
'abbr': 'C',
'name': 'C'
}]
}),
displayField: 'name',
valueField: 'abbr',
anchor: '100%',
value: data.rating,
},
{
xtype: 'combo',
fieldLabel: 'Language',
name: 'language',
store: Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data: [{
'abbr': '1',
'name': '1'
},{
'abbr': '2',
'name': '2'
},{
'abbr': '3',
'name': '3'
}]
}),
displayField: 'name',
valueField: 'abbr',
anchor: '100%',
value: data.language,
},{
xtype: 'textfield',
fieldLabel: 'Director',
name: 'Director',
anchor: '100%',
value: data.director,
},{
xtype: 'textarea',
name: 'Description',
fieldLabel: 'Description',
anchor: '100%',
value: data.description,
}],


buttons: [{
text: 'Save',
align: 'center',
formBind: true,
handler: function() {
var form = this.up('form').getForm();

if (form.isValid()) {
form.submit({
success: function(form, action) {
Ext.Msg.alert('Success');
},
failure: function(form, action) {
Ext.Msg.alert('Failed');
}
});
}
}
},{
text:'Cancel',
handler: function () {
this.up('window').close();
}
}]
}]
}).show();
},


},'-',{
xtype: 'button',
text: 'Delete',
textAlign: 'center',
id:'delbtn',
disable:true,
handler:function(){
var grid = Ext.getCmp('testGrid');
var x= grid.getSelectionModel().getSelection();
if(x.length==0)
Ext.Msg.alert('No record(s) to delete!!')
else
{
if(confirm('The selected record(s) will be deleted. Click OK to confirm'))
{

selected = [];
Ext.each(x, function (item) {
selected.push(item.get('film_id'));
});

var value= {"ids":selected};
Ext.Ajax.request({
url:'http://localhost:8080/Summer_Internship_Backend/deleteServlet',
params:value,
success: function(response){
var text= response.responseText;
Ext.Msg.alert('Success!!',text);

}
});
console.warn(value);

}
else
{
Ext.Msg.alert('No deletion will occur!!');
}
}
},
}
]
}],



columns: [{
text: 'Title',
dataIndex: 'title',
flex:0.5
}, {
text: 'Description',
dataIndex: 'description',
flex:0.5

}, {
text: 'Release Year',
dataIndex: 'release'
},
{
text:'Language',
dataIndex:'language'
},
{
text:'Director',
dataIndex:'director'
},
{
text:'Rating',
dataIndex:'rating'
},
{
text:'Special Feat...',
dataIndex:'features',
flex:0.5
},
{
text:'film_id',
dataIndex:'film_id',
hidden:true
}],
height: 270,
width: 1230,
renderTo: Ext.getBody(),
selModel: {
checkOnly: false,
injectCheckbox: 'first',
mode: 'SIMPLE',
type:'checkboxmodel',
},


});
}
});


win = Ext.create('Ext.window.Window', {
title: 'Add Fiilm',
height: 450,
width: 400,
target : document.getElementById('Add1'),
layout: 'fit',
items: {
xtype: 'form',
id:'myForm',
url:"http://localhost:8080/Summer_Internship_Backend/addServlet",
border: false,
closeAction:'close',
plain: true,
layout:'vbox',
items: [{
xtype: 'textfield',
fieldLabel: 'Title',
margin: '10 0 0 10',
name:'Title'
}, {
xtype: 'numberfield',
fieldLabel: 'release_Year',
margin: '10 0 0 10',
maxValue: 2021,
minValue: 1990,
name:'release_Year'
}, {
xtype: 'combobox',
fieldLabel: 'special_features',
margin: '10 0 0 10',
store:Ext.create('Ext.data.Store',{
fields:['abbr','name'],
data:[{
'abbr':'Trailors',
'name':'Trailors'
},{
'abbr':'Deleted Scenes',
'name':'Deleted Scenes'
},{
'abbr':'Behind Scenes',
'name':'Behind Scenes'
}],
}),
valueField: 'abbr',
displayField: 'name',
name:'special_features'
}, {
xtype: 'combobox',
fieldLabel: 'Rating',
margin: '10 0 0 10',
store:Ext.create('Ext.data.Store',{
fields:['abbr','name'],
data:[{
'abbr':'R',
'name':'R'
},{
'abbr':'PG',
'name':'PG'
},{
'abbr':'C',
'name':'C'
},{
'abbr':'NC-17',
'name':'PG'
},{
'abbr':'PG-13',
'name':'PG-13'
}],
}),
valueField: 'abbr',
displayField: 'name',
name:'Rating'

}, {
xtype: 'combobox',
fieldLabel: 'language',
margin: '10 0 0 10',
store:Ext.create('Ext.data.Store',{
fields:['abbr','name'],
data:[{
'abbr':'1',
'name':'1'
},{
'abbr':'2',
'name':'2'
},{
'abbr':'3',
'name':'3'
}],
}),
valueField: 'abbr',
displayField: 'name',
name:'language'
},{
xtype: 'textfield',
fieldLabel: 'Director',
margin: '10 0 0 10',
name:'Director'
},{
xtype: 'textarea',
fieldLabel: 'Description',
margin: '10 0 0 10',
name:'Description'
}], buttons: [{
text: 'Save',
margin:'0 20 0 0',
handler:
function () {
var form = this.up("form").getForm();
if (form.isValid()) {
form.submit({
success: function (form, action) {
Ext.Msg.alert("Success!", action.response.status);
store.reload();
},
failure: function (form, action) {
Ext.Msg.alert("Failed", "Please try again!");
// console.log(action.response.status);
}})}},

}],
store: Ext.create('Ext.data.ArrayStore', {})
}
});







package com.slimfast.DAO;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

import com.slimfast.movie;
import com.slimfast.Modal.movie_pojo;

public class movieDB_implementation implements moviedb {

ArrayList<movie_pojo> custList= new ArrayList<movie_pojo>();
Configuration con= new Configuration().configure().addAnnotatedClass(movie_pojo.class);
@SuppressWarnings("deprecation")

ServiceRegistry reg= new ServiceRegistryBuilder().applySettings(con.getProperties()).build();
SessionFactory sf= con.buildSessionFactory(reg);
public ArrayList<movie_pojo> getAllMovies(int start, int limit, String title, String director, String language,int release_year)
{
Connection con=null;
try {
/*@SuppressWarnings("unused")
Statement stmt=null;
@SuppressWarnings("unused")
String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
Class.forName(JDBC_DRIVER);
DriverManager.registerDriver(new com.mysql.jdbc.Driver());

String mysqlUrl="jdbc:mysql://localhost:3306/sakila";
con = DriverManager.getConnection(mysqlUrl,"root","root");
stmt=con.createStatement();

if(title!=null && director!=null && language!=null) {

ResultSet rs = con.createStatement().executeQuery("select * from film where title='" + title + "' && director='" + director + "'&& release_year='" + release_year + "'&& language_id='" + language + "' && isDeleted=0 ");

System.out.print(rs);
while(rs.next()) {
movie_pojo custObj= new movie_pojo();
custObj.setTitle(rs.getString("title"));
custObj.setDescription(rs.getString("description"));
custObj.setRelease(Integer.parseInt(rs.getString("release_year").substring(0,4))));
custObj.setLanguage(rs.getString("language_id"));
custObj.setDirector(rs.getString("director"));
custObj.setRating(rs.getString("rating"));
custObj.setFeatures(rs.getString("special_features"));
custObj.setfilm_id(rs.getInt("film_id"));

custList.add(custObj);
}

}
else {
ResultSet rs = con.createStatement().executeQuery("SELECT * from film where isDeleted=0 limit "+start + ","+limit+";");
System.out.print(rs);
while(rs.next()) {
movie_pojo custObj1= new movie_pojo();
custObj1.setTitle(rs.getString("title"));
custObj1.setDescription(rs.getString("description"));
custObj1.setRelease(rs.getInt("release_year"));
custObj1.setLanguage(rs.getString("language_id"));
custObj1.setDirector(rs.getString("director"));
custObj1.setRating(rs.getString("rating"));
custObj1.setFeatures(rs.getString("special_features"));
custObj1.setfilm_id(rs.getInt("film_id"));

custList.add(custObj1);
}
}*/
if(title!=null && director!=null && language!=null) {
Session session=sf.openSession();
Transaction tx= session.beginTransaction();
Query q=session.createQuery("From movie_pojo as mp where mp.title=:t AND mp.director=:d AND mp.language=:l AND mp.director=:d AND mp.release=:r");
q.setParameter("t", title);
q.setParameter("d", director);
q.setParameter("l", language);
q.setParameter("r", release_year);
List data1 =q.list();
for(Iterator it= data1.iterator();it.hasNext();)
{
movie_pojo ob=(movie_pojo) it.next();
custList.add(ob);
}
tx.commit();
}

else {
Session session=sf.openSession();
Transaction tx= session.beginTransaction();
Query q=session.createQuery("From movie_pojo where isDeleted=0");
q.setFirstResult(start);
q.setMaxResults(limit);
List data1 =q.list();
for(Iterator it= data1.iterator();it.hasNext();)
{
movie_pojo ob=(movie_pojo) it.next();
custList.add(ob);
}
tx.commit();
}
}catch(Exception e)
{
e.printStackTrace();
System.out.println("Ërror in DAO Impl");
}
finally {
try
{
if(con!=null)
con.close();

}
catch(SQLException se)
{
se.printStackTrace();
}
}
return custList;
}
public Boolean addMovies(String title,int release,String features,String rating,String language,String director,String description) {
try {


// Initialize the database

//String JDBC_DRIVER = "com.mysql.jdbc.Driver";

/*String DB_URL = "jdbc:mysql://localhost:3306/sakila";
String USER = "root";
String PASS = "root";
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection(DB_URL,USER,PASS);

// Create a SQL query to insert data into demo table
// demo table consists of two columns, so two '?' is used
String sql = "INSERT INTO film (title, release_year,special_features,rating,language_id,director,description) VALUES (?,?,?,?,?,?,?)";
PreparedStatement statement = con.prepareStatement(sql);
statement.setString(1,title);
statement.setInt(2,release);
statement.setString(3,features);
statement.setString(4,rating);
statement.setString(5,language);
statement.setString(6,director);
statement.setString(7,description);

statement.executeUpdate();

// Close all the connections
statement.close();
con.close(); */
Session session=sf.openSession();
Transaction tx= session.beginTransaction();
movie_pojo mp=new movie_pojo();
mp.setTitle(title);
mp.setDescription(description);
mp.setLanguage(language);
mp.setRelease(release);
mp.setRating(rating);
mp.setDirector(director);
mp.setFeatures(features);
session.save(mp);

tx.commit();

}
catch (Exception e) {
e.printStackTrace();
}
return true;

}
public Boolean EditMovies(int film_id,String title,int release_year,String special_features,String rating,int language,String director,String description) {
//String DRIVER="com.mysql.cj.jdbc.Driver";
//String URL="jdbc:mysql://localhost:3306/sakila";
//String UN="root";
//String PW="root";
try {
/*Class.forName(DRIVER);
try {
Connection cn=DriverManager.getConnection(URL,UN,PW);
PreparedStatement pst=cn.prepareStatement("UPDATE film SET title=?,release_year=?,special_features=?,rating=?,language_id=?,director=?,description=? WHERE film_id=?");
pst.setString(1, title);
pst.setInt(2, release_year);
pst.setString(3, special_features);
pst.setString(4, rating);
pst.setInt(5, language);
pst.setString(6, director);
pst.setString(7, description);
pst.setInt(8, film_id);

pst.executeUpdate();

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
Session session=sf.openSession();
Transaction tx= session.beginTransaction();
Query q=session.createQuery("update movie_pojo set title=:t, description=:d, release=:r, language=:l, rating=:ra, director=:di where film_id=:f");
q.setParameter("t", title);
q.setParameter("d", description);
q.setParameter("r", release_year);
q.setParameter("l",Integer.toString(language));
q.setParameter("ra", rating);
q.setParameter("di", director);
q.setParameter("f",film_id);
q.executeUpdate();
tx.commit();

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
public Boolean DeleteMovie(String []ids) {
try {


// Initialize the database

//String JDBC_DRIVER = "com.mysql.jdbc.Driver";

//String DB_URL = "jdbc:mysql://localhost:3306/sakila";
//String USER = "root";
//String PASS = "root";
//Class.forName("com.mysql.cj.jdbc.Driver");
//Connection con = DriverManager.getConnection(DB_URL,USER,PASS);

// Create a SQL query to insert data into demo table
// demo table consists of two columns, so two '?' is used
//String delete="UPDATE film set isDeleted=1 where film_id=?;";







// for(int i=0;i<ids.length;i++)
// {
// PreparedStatement ps=con.prepareStatement(delete);
// ps.setLong(1,Long.parseLong(ids[i]));
// ps.executeUpdate();
// }


// Close all the connections

//con.close();
Session session=sf.openSession();
Transaction tx= session.beginTransaction();
for(int i=0;i<ids.length;i++) {
Query q=session.createQuery("update movie_pojo as mp set isDeleted=1 where mp.film_id=:ids");
q.setParameter("ids", Integer.parseInt(ids[i]));
q.executeUpdate();

tx.commit();

}

}
catch (Exception e) {
e.printStackTrace();
}
return true;
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.