id
stringlengths
36
36
text
stringlengths
1
1.25M
135ce54d-f11b-4ded-b53d-38a060771ff2
public Collection<Chanson> findAllChanson();
45744cc2-5b7d-4196-a0bf-66d8af95a296
public void updateChanson(Chanson ch);
65ff546c-e732-4d82-a401-cbf9f4a77607
public void deleteChanson(Chanson ch);
54322caf-1ad2-4189-a3b5-ccdc448e5985
void createChanson(Chanson ch);
a3a4b9d9-8a1d-4d08-8fb6-9c317529533b
public Chanson findChanson(Integer id);
85d397dd-85ec-4157-9a25-86b720eb068f
public ArtisteDaoImpl() { // TODO Auto-generated constructor stub }
53698133-193a-4307-84b8-cef598465053
@Autowired public void setSessionFactory(SessionFactory s){ //Configuration cfg= new Configuration(); this.sessionFactory=s; }
613db6ef-7c62-4849-b78d-d600e575d24e
public static Artiste findArtisteByName(String name){ Query q=sessionFactory.getCurrentSession().createQuery("from Artiste A Where A.nom=:name"); q.setString("name",name); return (Artiste) q.uniqueResult(); }
a7eea2de-41b8-43d2-be6b-48c1cc46beec
@Override public Collection<Artiste> findAllArtiste() { // TODO Auto-generated method stub return sessionFactory.getCurrentSession().createQuery("from Artiste").list(); }
b5ff4197-fc70-4667-91ec-efde3649ffb9
@Override public Artiste findArtiste(Integer id) { // TODO Auto-generated method stub return (Artiste) this.sessionFactory.getCurrentSession().get(Artiste.class, id); }
73e3b50d-7b79-48a1-8fa6-3f5543e06f2b
@Override public void createArtiste(Artiste art) { // TODO Auto-generated method stub sessionFactory.getCurrentSession().save(art); }
211f86a5-26ea-48ac-acb4-f6f40cc4bcf2
@Override public void delArtiste(Artiste art) { // TODO Auto-generated method stub Artiste a=(Artiste) sessionFactory.getCurrentSession().get(Artiste.class,findArtisteByName(art.getNom()).getId()); if (a!=null){ sessionFactory.getCurrentSession().delete(a); } else{ System.out.println("Artiste not found...
41f3fb88-716b-4ea1-895c-a6ce4af14278
@Override public void upArtiste(Artiste art) { // TODO Auto-generated method stub Artiste a=(Artiste) sessionFactory.getCurrentSession().get(Artiste.class,art.getId()); if (a!=null){ if (art.getNom()!=a.getNom()) a.setNom(art.getNom()); if (art.getCodeArtiste()!=a.getCodeArtiste()) a.setCodeArtiste...
98bce805-dbe8-4943-83ba-1e1b3ce3e98f
public AlbumService() { // TODO Auto-generated constructor stub }
a0c8a24b-3cdd-4525-bb5b-5b646735635b
public Collection<Album> findAllAlbum() { // TODO Auto-generated method stub return aDao.findAllAlbum(); }
0c0c1ffa-99f5-4e15-8d2b-755044425109
public Album findAlbum(Integer id) { // TODO Auto-generated method stub return (Album) aDao.findAlbum(id); }
2ee801fa-ef62-4f41-81a2-74486f258777
public void createAlbum(Album alb) { // TODO Auto-generated method stub aDao.createAlbum(alb); }
de37f5ad-bbe6-446d-ad60-b43e4b974c89
public void delAlbum(Album alb){ aDao.delAlbum(alb); }
2deaea38-1638-492d-9c83-0a983f7a0096
public void upAlbum(Album alb){ aDao.upAlbum(alb); }
ac5f8d1f-d6e8-43a0-bb42-3fb910a80f16
public ChansonService() { // TODO Auto-generated constructor stub }
26db7afd-563f-4357-81c2-3046003e3456
public Collection<Chanson> findAllChanson(){ return cDao.findAllChanson(); }
5890167e-5d70-4772-ba4b-c8667f7cf12b
public Chanson findChanson(int num){ return cDao.findChanson(num); }
d99a34f7-968c-4b5a-88a0-be6acd09a18d
public void createChanson(Chanson c){ cDao.createChanson(c); }
3182a554-991d-4c85-b4b3-21ea09442b86
public void deleteChanson(Chanson c){ cDao.deleteChanson(c); }
8d1adbf1-3ced-43a8-99ce-a905bd765ef1
public void updateChanson(Chanson c){ cDao.updateChanson(c); }
d0630c31-f8fc-4aae-b667-862247a8286f
public ArtisteService() { // TODO Auto-generated constructor stub }
653931b3-e336-4378-985c-29b08c6238ec
public Collection<Artiste> findAllArtiste(){ return aDao.findAllArtiste(); }
843b6b97-5123-4678-b272-77d3b63f67f5
public void createArtiste(Artiste art){ aDao.createArtiste(art); }
fbdf9374-2ed7-44c4-acb2-bda4ced46223
public Artiste findArtiste(int id){ return aDao.findArtiste(id); }
57af2d91-4a3e-4426-86e6-b15e4f100148
public void delArtiste(Artiste art){ aDao.delArtiste(art); }
1ace8cd0-2553-44a8-a7ee-3a33e07908b0
public void upArtiste(Artiste art){ aDao.upArtiste(art); }
e7af0122-c3f8-4987-b103-8b86db78b2ab
@Test public void test() { List<String> sample = Arrays.asList(new String[]{"abcdde","baccd","eeabg"}); assertEquals(2,Solution.findGemCount(sample)); }
a3e5b5f4-4613-4728-9a79-baa9db352a25
@Test public void smallestVechileShouldGo() { int[] widhtArray = {2,3,1,2,3,2,3,3}; assertEquals(1,Solution.getVehiclesType(0, 3, widhtArray)); assertEquals(2,Solution.getVehiclesType(4, 6, widhtArray)); assertEquals(3,Solution.getVehiclesType(6, 7, widhtArray)); assertEquals(2,Solution.getVehiclesType(3, 5...
f5eb5f91-0aca-4320-b42f-33366bda72ac
@Test public void testLongInput() throws Exception { int[] width = {2,2,2,2,3,3,3,3,3,3,2,3,3,3,2,2,2,3,3,3,2,2,2,2,2,2,3,3,3,2,3,3,3,3,2,2,2,3,3,2,2,3,3,3,3,2,2,3,3,3,2,3,3,3,3,3,3,3,2,2,3,3,2,2,3,2,3,3,3,2,3,3,2,3,2,3,3,2,2,2,3,2,3,3,3,2,2,3,3,3,3,3,2,3,3,3,3,2,3,2,3,2,3,3,3,2,2,2,2,2,2,2,2,3,3,2,2,3,3,3,2,2,2,3,2...
1ac7dd63-fc83-45e3-9443-24cea9464c5b
@Test public void verifyPalindrome() { assertTrue(Solution.isPalindromes("aaa")); assertTrue(Solution.isPalindromes("abba")); assertFalse(Solution.isPalindromes("vijay")); }
91e73d0b-14b5-4f57-b90d-8702887235e5
@Test public void verifyCountMove() throws Exception { assertEquals(2, Solution.countToPalindromes("abc")); assertEquals(0, Solution.countToPalindromes("abcba")); assertEquals(4, Solution.countToPalindromes("abcd")); assertEquals(11, Solution.countToPalindromes("vijay")); }
91f2786e-b1e0-431b-af96-b71bfe4e9994
@Test public void verifySolutionForZeroItireation() { assertEquals(1, Solution.heightOfTree(0)); }
b7892546-02d7-4c11-acd4-55e7eb25641c
@Test public void verifySolutionForOddItireations() throws Exception { assertEquals(2, Solution.heightOfTree(1)); assertEquals(6, Solution.heightOfTree(3)); }
5b57f717-d48d-49bd-a11e-133ea2060a8f
@Test public void verifyEvenItirations() throws Exception { assertEquals(7, Solution.heightOfTree(4)); assertEquals(15, Solution.heightOfTree(6)); }
38e949f1-2fbb-4e3e-95e3-6458db3470b0
@Test public void test() { assertEquals(6,Solution.getmaxSquares(5)); assertEquals(9,Solution.getmaxSquares(6)); assertEquals(12,Solution.getmaxSquares(7)); assertEquals(16,Solution.getmaxSquares(8)); }
5ac85625-ac98-4f47-8f5b-5ecac3c338ac
@Test public void testBuildTheList() { LinkListOnPlane linkList = new LinkListOnPlane(1, 2); linkList.insert(2, 3); linkList.insert(2, 4); linkList.insert(2, 5); linkList.insert(3, 4); linkList.insert(4, 4); linkList.insert(5, 4); assertTrue(linkList.size()==7); linkList.removePointsInLine(); asser...
9b8b0161-10d6-4edc-95d2-05aead8cc093
@Test public void test() { int[] a1 = { 2, 1, 2, 5, 7, 1, 9, 3, 6, 8, 8 }; int[] a2 = { 2, 1, 8, 3 }; int[] sorted = RefArraySort.sort(a1, a2); for(int i : sorted){ System.out.println(i); } }
9289ddce-ef57-4ad1-b56d-33bc0bf19aab
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int a = scanner.nextInt(); int b = scanner.nextInt(); int c = sum(a,b); System.out.println(c); scanner.close(); }
cafc2b14-6d8a-46ab-b1ce-1cd95427a204
private static int sum(int a, int b) { return a+b; }
e1e945b9-3d7c-4f16-a461-fa2bf6a42256
public static void main(String[] args) throws FileNotFoundException { Scanner scanner = new Scanner(new File( "/home/vijay/Desktop/hr/input04.txt")); int noOftestCases = Integer.parseInt(scanner.nextLine()); List<String> samples = new ArrayList<String>(noOftestCases); for (int i = 0; i < noOftestCases; i++)...
736a5f26-18a1-4b3b-9cd7-ccb3e1fd8836
protected static int findGemCount(List<String> samples) { int count = 0; Pattern pattern = Pattern.compile("[a-zA-Z]"); String minLenStr = samples.stream() .min((s1, s2) -> s1.length() - s2.length()).get(); Matcher matcher = pattern.matcher(minLenStr); Set<String> uniuqe = new HashSet<String>(); while (...
e74768cb-14c3-468e-8afb-566febfbaa4b
public static void main(String[] args) throws FileNotFoundException { Scanner scanner = new Scanner(System.in); String inputLine1 = scanner.nextLine(); Pattern p = Pattern.compile("\\d+"); Matcher matcher = p.matcher(inputLine1); int length = 0; if (matcher.find()) { length = Integer.parseInt(matcher.gro...
660535b5-e5be-4e8f-8297-62c807321644
protected static int getVehiclesType(int entry, int exit, int[] widhtArray) { int min = widhtArray[entry]; for (int i = entry + 1; i <= exit; i++) { if (min > widhtArray[i]) { min = widhtArray[i]; } } return min; }
872d81c1-c4df-4ba7-b8f6-24e192105d14
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int noOftestCases = Integer.parseInt(scanner.nextLine()); for (int i = 0; i < noOftestCases; i++) { String testCase = scanner.nextLine(); int moves = countToPalindromes(testCase); System.out.println(moves); } scanner.c...
faff95bd-a1c7-4b80-b10b-e98858393c32
protected static int countToPalindromes(String testCase) { int i = 0, j = testCase.length() - 1; int moves = 0; while (i <= j) { int c = (int) testCase.charAt(i++); int d = (int) testCase.charAt(j--); if (c > d) { moves = moves + (c - d); } else { moves = moves + (d - c); } } return mo...
46d19314-2504-4f89-924a-d5c4b35e4e40
protected static boolean isPalindromes(String testCase) { int j = testCase.length() - 1; for (int i = 0; i < testCase.length(); i++) { if (testCase.charAt(i) != testCase.charAt(j)) { return false; } j--; } return true; }
a534de14-8711-4f6b-b5e1-9b2ec757d31c
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int noOfTest = scanner.nextInt(); for (int i = 0; i < noOfTest; i++) { System.out.println(heightOfTree(scanner.nextInt())); } scanner.close(); }
704d62a7-5e63-481f-aaff-e30a2783df3b
protected static int heightOfTree(int nextInt) { int height = 1; for (int i = 1; i <= nextInt; i++) { if (i % 2 == 0) { height++; } else { height *= 2; } } return height; }
202f90e5-cfdc-4c4b-b83e-7001bd15bf90
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int testCases = scanner.nextInt(); for (int i = 0; i < testCases; i++) { long cuts = scanner.nextLong(); System.out.println(getmaxSquares(cuts)); } scanner.close(); }
4f45c6ac-837c-4e37-83da-abfab8e9e307
protected static long getmaxSquares(long cuts) { long v = 1; long h = cuts - v; long max = 0; while (h >= 1) { long squares = getSquares(v++, h--); if (squares > max) { max = squares; } } return max; }
d0a93909-2bf3-4346-9af6-c8292dcfc97c
protected static long getSquares(long v, long h) { return h * v; }
2d318e09-db95-4017-a496-31707e556d64
public Node getHead() { return head; }
63a35ea6-55e4-4181-a8d9-8d43bbcbc59e
public LinkListOnPlane(int x, int y) { head = new Node(x, y); }
709c2017-c793-4cf6-9aff-f6e614b1d4f5
public void insert(int x, int y) { if (head == null) { throw new UnsupportedOperationException("Head of the list in Null"); } Node loc = head; Node next = head.next(); while (next != null) { loc = next; next = next.next(); } loc.addLink(new Node(x, y)); }
13677ab5-205f-4aca-8a1b-730f66ea5606
public void print() { if (head == null) { throw new UnsupportedOperationException( "Can't Print a list with null head"); } Node current = head; while (current != null) { System.out.print(current); current = current.next(); if (current != null) { System.out.print("-->"); } } }
0b6f2459-e9aa-43ac-9c5e-959635dcd882
public void removePointsInLine() { Node prev = head; Node next = head.next(); while (next != null) { if (prev.getX() == next.getX() && next.next() != null && next.getX() == next.next().getX()) { prev.addLink(next.next()); } else if (prev.getY() == next.getY() && next.next() != null && next.get...
fa8d6b56-867e-4409-bf65-2428de9772d0
public int size() { int count = 0; Node current = head; while (current != null) { current = current.next(); count++; } return count; }
34e8bc48-5477-4cb8-bde1-955660d83293
public Node(int x, int y) { this.x = x; this.y = y; }
462f369e-2c45-4c2b-8666-a608fc1bc1c8
public Node next() { return this.next; }
8412eedd-41fe-4601-b2a3-63440b821837
public void addLink(Node next) { this.next = next; }
79c606df-fae8-4378-9a33-18930443bc5d
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("(").append(x).append(",").append(y).append(")"); return sb.toString(); }
6b2913ab-54b9-4ee7-bbb5-7e049cb8edbf
public int getX() { return this.x; }
0fc85c99-889d-4dfe-a5e4-bddd7ef4e4de
public int getY() { return this.y; }
e8044a52-5518-4e6e-bcab-5bb370386dc2
public static int[] sort(int[] input, int[] ref) { inputSet = input; scoreMap = new LinkedHashMap<Integer, Integer>(); int weight = ref.length; for (int i : ref) { scoreMap.put(i, weight--); } int mid = inputSet.length / 2; return merge(divide(0, mid), divide(mid + 1, inputSet.length - 1)); }
2d550d8f-eadf-4531-ad2c-ea6b19980657
private static int[] divide(int left, int right) { if (right - left == 0) { return new int[] { inputSet[left] }; } else if (right - left == 1) { return merge(new int[] { inputSet[left] }, new int[] { inputSet[right] }); } int mid = (left + right) / 2; return merge(divide(left, mid), divide(mid + 1,...
80778e16-f138-4866-b4c9-e3c8614e909d
private static int[] merge(int[] left, int[] right) { int[] sorted = new int[left.length + right.length]; int j = 0, k = 0; for (int i = 0; i < left.length + right.length; i++) { if (j >= left.length) { sorted[i] = right[k]; k++; } else if (k >= right.length) { sorted[i] = left[j]; j++; }...
1136f037-d408-4eec-b0bc-03dd69546d97
public static void hashFolder() throws IOException { File deployFolder = new File("deploy"); if (!deployFolder.exists()) deployFolder.mkdir(); ArrayList<File> files = new ArrayList<File>(); PathUtil.listf("files", files); StringBuilder builder = new StringBuilder(); for (File file : files) { FileInputSt...
9d16bf04-c831-4d9d-a8ed-4033ffb1a6ff
public static void main(String args[]) throws IOException { if (args.length == 0) { hashFolder(); return; } String zipPath = args[0]; File zipFile = new File(zipPath); if (zipFile.exists() && zipFile.isFile()) { File filesDirectory = new File("files"); if (!filesDirectory.exists()) { filesDir...
a91255c6-7fb9-4019-8f9e-ac292759ede2
public static void main(String[] args) throws IOException { Properties serverProperties = loadConfig(); int port = Integer.parseInt(serverProperties.getProperty("server.port")); long updateRate = Long.parseLong(serverProperties.getProperty("cache.lifetime")); logger.addHandler(new FileHandler("server.log")); ...
eaa7fb6d-e0af-44f0-98e1-bab1fbe2199a
public static Properties loadConfig() throws IOException { File configFile = new File("config.properties"); if (!configFile.exists()) { configFile.createNewFile(); } FileInputStream configInputStream = new FileInputStream(configFile); Properties configProperties = new Properties(); configProperties.load(...
81ee6d4f-a5d9-410d-a3a0-8f630695f693
public FilesHandler(long cacheUpdateRate) { super(cacheUpdateRate, Logger.getLogger("FilesHandler")); }
5486c728-c358-4b00-9143-342d39f1ab4f
@Override public void handle(HttpExchange httpExchange) throws IOException { testCache(); HttpPatchServer.logger.fine("requested /files handler"); httpExchange.getResponseHeaders().add("Content-type", "application/octet-stream"); httpExchange.sendResponseHeaders(200, cacheData.get(httpExchange.getRequestUR...
d0cfa877-227e-4f77-8370-59e33cb67663
@Override public void reloadCache() throws IOException { cacheData = new HashMap<String, byte[]>(); ArrayList<File> files = new ArrayList<File>(); PathUtil.listf("files", files); for (File file : files) { byte[] data = new byte[(int)file.length()]; FileInputStream zipInputStream = new FileInputStream(f...
479fd09b-89b0-41fe-9645-a4915dc85f3e
public HashHandler(long cacheUpdateRate) { super(cacheUpdateRate, Logger.getLogger("HashHandler")); }
9657d8ab-b0fa-4c80-b595-e548d504cadc
@Override public void handle(HttpExchange httpExchange) throws IOException { testCache(); httpExchange.getResponseHeaders().add("Content-type", "text/plain"); httpExchange.sendResponseHeaders(200, cacheData.length()); try (OutputStream outputStream = httpExchange.getResponseBody()) { outputStream.write(cach...
f81b080b-33a3-4877-8617-434f25ae6170
@Override public void reloadCache() throws IOException { StringBuilder builder = new StringBuilder(); List<String> hashData = Files.readAllLines(FileSystems.getDefault().getPath("deploy/hash"), Charset.forName("UTF-8")); for (String line : hashData) { builder.append(line); builder.append(System.lineSeparat...
207350c0-ad0d-4e54-a08d-deb04150bff8
public CachedHandler(long cacheUpdateRate, Logger logger) { this.cacheUpdateRate = cacheUpdateRate; this.logger = logger; }
78ec10fc-d572-48f5-8837-bac59d291bdc
public abstract void reloadCache() throws IOException;
993c495b-24ef-4c76-9375-b3b0e6821565
public void testCache() throws IOException { if (System.currentTimeMillis() - lastCacheUpdate > cacheUpdateRate) { reloadCache(); logger.info("Cache reloaded"); lastCacheUpdate = System.currentTimeMillis(); } }
85e114f8-7f39-4d88-9a6f-d80bd20c75ee
public PatchHandler(long cacheUpdateRate) { super(cacheUpdateRate, Logger.getLogger("PatchHandler")); }
18d0cbc0-be2b-4502-bdd5-b22c52cdc9ec
@Override public void handle(HttpExchange httpExchange) throws IOException { testCache(); httpExchange.getResponseHeaders().add("Content-type", "application/zip"); httpExchange.sendResponseHeaders(200, cacheData.length); try (OutputStream zipOutputStream = httpExchange.getResponseBody()) { zipOutputStream.w...
bbfbd058-e011-4495-8629-6fa16b164491
@Override public void reloadCache() throws IOException { File file = new File("deploy/patch.zip"); cacheData = new byte [(int)file.length()]; FileInputStream zipInputStream = new FileInputStream(file); try (BufferedInputStream bufferedInputStream = new BufferedInputStream(zipInputStream)) { bufferedInputStr...
a8f2fa3f-f58b-4314-aca9-948410f557ac
public void unzip(String zipFilePath, String destDirectory) throws IOException { File destDir = new File(destDirectory); if (!destDir.exists()) { destDir.mkdir(); } ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath)); ZipEntry entry = zipIn.get...
5fec910d-be18-4add-bea9-f264dd7f5d56
private void extractFile(ZipInputStream zipIn, String filePath) throws IOException { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath)); byte[] bytesIn = new byte[BUFFER_SIZE]; int read = 0; while ((read = zipIn.read(bytesIn)) != -1) { bos.wri...
147d6caa-465e-4f08-8056-b9fb1db0f313
public static void listf(String directoryName, ArrayList<File> files) { File directory = new File(directoryName); // get all the files from a directory File[] fList = directory.listFiles(); for (File file : fList) { if (file.isFile()) { files.add(file); } else if (fil...
bfba70e5-2bdb-4f29-a978-002ea8fb1d80
public void run() { try { final BufferedReader br = new BufferedReader(new InputStreamReader(is), 50 /* * keep *...
6f94adf4-683b-405f-86ab-cc0bbb92df03
Receiver(InputStream is) { this.is = is; }
5ab38800-2cd4-478b-84c8-e5026e446184
public String toSvg(String dot) { log.debug("create svg from dot"); File dotFile = null; File svgFile = null; try { /* write the dot to a temporary file */ dotFile = File.createTempFile("graphviz", ".dot"); FileWriter writer = new Fil...
01831e2e-3ccb-4bc7-b6a6-95be99b59bdd
public void setDotCommand(String dotCommand) { this.dotCommand = dotCommand; }
c55f9c23-f7c1-4f1f-8ad1-7f815efcb122
public String getDotCommand() { return dotCommand; }
0e6f7e1a-cf9d-41c4-a83a-30432f330b03
@RequestMapping(value = "svg", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) public final void toSvg( @RequestBody Dot2Svg body, HttpServletResponse response) throws IOException { log.debug("create svg from dot"); log.debug("body: {}", body);...
ecf7a653-a2af-4631-8538-d38b8aed7c7c
public String getDot() { return dot; }
89b0dcea-9a16-4928-a8b7-e10567c14257
public void setDot(String dot) { this.dot = dot; }
fb688ac1-5f47-4734-a7fa-51f421244057
@Override public String toString() { return dot; }
68fa080d-38d0-4516-af75-f0662b246627
@Bean public static PropertyPlaceholderConfigurer properties() { PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); final Resource[] resources = new ClassPathResource[] { // new ClassPathResource("persistence.properties"), // new ClassPathResou...