@EventHandler public void onPingServList(ServerListPingEvent e) { if (this.pl.aguardando) { // e.setMotd("§a§l» §b§o§lCooler - HG §a§l « §6§oAguardando os jogadores \n§a§o Entre em nosso // site: (Em breve)"); e.setMotd("§a[Entrar]"); } if (this.pl.comecando) { int millis = this.pl.startingCounter * 1000; SimpleDateFormat df = new SimpleDateFormat("m:ss"); String time = df.format(Integer.valueOf(millis)); // e.setMotd("§a§l» §b§o§lCooler - HG §a§l « §6§oPartida inicia em: " + time + "\n§a§oEntre em // nosso site: (Em breve)"); e.setMotd("§a[Entrar]"); } if ((this.pl.invencibilidade) && (Join.getOnlinePlayers() == 0)) { // e.setMotd("§a§l» §b§o§lCooler - HG §a§l « §c§oServidor vai reiniciar \n§a§o Entre em nosso // site: (Em breve)"); Bukkit.getServer().shutdown(); e.setMotd("§c[Reiniciando]"); } if ((this.pl.comecou) && (Join.getOnlinePlayers() == 0)) { // e.setMotd("§a§l» §b§o§lCooler - HG §a§l « §c§oServidor vai reiniciar \n§a§o Entre em nosso // site: (Em breve)"); Bukkit.getServer().shutdown(); e.setMotd("§c[Reiniciando]"); } if (this.pl.invencibilidade) { int millis = this.pl.invicCounter * 1000; SimpleDateFormat df = new SimpleDateFormat("m:ss"); String time = df.format(Integer.valueOf(millis)); // e.setMotd("§a§l» §b§o§lCooler - HG §a§l « §6§oInvencibilidade acaba em: " + time + "\n§a§o // Entre em nosso site: (Em breve)"); e.setMaxPlayers(Integer.valueOf(this.pl.vivos.size())); e.setMotd("§5[Em Jogo]"); } if (this.pl.comecou) { int millis = this.pl.partidaCounter * 1000; SimpleDateFormat df = new SimpleDateFormat("m:ss"); String time = df.format(Integer.valueOf(millis)); // e.setMotd("§a§l §b§o§lCooler - HG §a§l « §c§oJogo em progresso: " + time + "\n§a§o Entre em // nosso site: (Em breve)"); e.setMaxPlayers(Integer.valueOf(this.pl.vivos.size())); e.setMotd("§5[Em Jogo]"); } if (this.pl.acabou) { // e.setMotd("§a§l» §b§o§lCooler - HG §a§l « §c§oServidor vai reiniciar \n§a§o Entre em nosso // site: (Em breve)"); e.setMaxPlayers(Integer.valueOf(this.pl.vivos.size())); e.setMotd("§c[Reiniciando]"); } if ((this.pl.acabou) && (Join.getOnlinePlayers() == 0)) { // e.setMotd("§a§l» §b§o§lCooler - HG §a§l « §c§oServidor vai reiniciar \n§a§o Entre em // nosso site: (Em breve)"); Bukkit.getServer().shutdown(); e.setMotd("§c[Reiniciando]"); } }
public final void testJoin() { assertEquals("", Join.join("")); assertEquals("", Join.join("foo")); assertEquals("barFOObaz", Join.join("FOO", "bar", "baz")); assertEquals("barFOObazFOO", Join.join("FOO", "bar", "baz", "")); assertEquals(",,,", Join.join(",", "", "", "", "")); }
@Override public void execute(final Object message) throws Exception { final Class<?> klass = message.getClass(); if (Join.class.equals(klass)) { final Join request = (Join) message; internalLinkEndpoint = request.endpoint(); internalLinkMode = request.mode(); } gateway.tell(new CreateLink(session), source); }
public Map<String, Construct> evaluate(BindableEvent e) throws EventException { Map<String, Construct> retn = new HashMap<String, Construct>(); if (e instanceof Join) { Join msg = (Join) e; retn.put("id", new CString(msg.getBot().getID(), Target.UNKNOWN)); retn.put("who", new CString(msg.getWho(), Target.UNKNOWN)); retn.put("channel", new CString(msg.getChannel(), Target.UNKNOWN)); } return retn; }
/** Displays LoginScreen */ private void displayLogin() { // true back.setVisible(true); Login.setVisible(true); Login2.setVisible(true); SmallInput.setVisible(true); SmallInput2.setVisible(true); SmallInput3.setVisible(true); SmallInput4.setVisible(true); SmallInput5.setVisible(true); CreateNewAccount.setVisible(true); Create.setVisible(true); username.setVisible(true); password.setVisible(true); newUsername.setVisible(true); newPassword.setVisible(true); verifyPassword.setVisible(true); loginCreate.setVisible(true); loginCreate.setOpaque(false); // false serversError.setVisible(false); Credits.setVisible(false); NetworkMode.setVisible(false); Online.setVisible(false); Lan.setVisible(false); Servers.setVisible(false); BigInput2.setVisible(false); LongInput.setVisible(false); LongInput2.setVisible(false); Join.setVisible(false); Create2.setVisible(false); returnToMain.setVisible(false); ip.setVisible(false); serverName.setVisible(false); }
@SuppressWarnings("unchecked") public static Predicate[] deviceListPredicates( CriteriaBuilder cb, Root<Device> from, Optional<String> name, Optional<String> namePattern, Optional<String> status, Optional<Long> networkId, Optional<String> networkName, Optional<Long> deviceClassId, Optional<String> deviceClassName, Optional<String> deviceClassVersion, Optional<HivePrincipal> principal) { final List<Predicate> predicates = new LinkedList<>(); name.ifPresent(n -> predicates.add(cb.equal(from.<String>get("name"), n))); namePattern.ifPresent(np -> predicates.add(cb.like(from.<String>get("name"), np))); status.ifPresent(s -> predicates.add(cb.equal(from.<String>get("status"), s))); final Join<Device, Network> networkJoin = (Join) from.fetch("network", JoinType.LEFT); networkId.ifPresent(nId -> predicates.add(cb.equal(networkJoin.<Long>get("id"), nId))); networkName.ifPresent( nName -> predicates.add(cb.equal(networkJoin.<String>get("name"), nName))); final Join<Device, DeviceClass> dcJoin = (Join) from.fetch("deviceClass", JoinType.LEFT); deviceClassId.ifPresent(dcId -> predicates.add(cb.equal(dcJoin.<Long>get("id"), dcId))); deviceClassName.ifPresent( dcName -> predicates.add(cb.equal(dcJoin.<String>get("name"), dcName))); deviceClassVersion.ifPresent( dcVersion -> predicates.add(cb.equal(dcJoin.<String>get("version"), dcVersion))); predicates.addAll(deviceSpecificPrincipalPredicates(cb, from, principal)); return predicates.toArray(new Predicate[predicates.size()]); }
@Override public void visit(SubJoin subJoin) { FromItem left = subJoin.getLeft(); FromItem right = subJoin.getJoin().getRightItem(); FromItemVisitorImpl leftVisitor = new FromItemVisitorImpl(where); FromItemVisitorImpl rightVisitor = new FromItemVisitorImpl(where); left.accept(leftVisitor); right.accept(rightVisitor); relationProvider = PlanFactory.getInstance().newJoin(); ((Join) relationProvider) .setInput(leftVisitor.getRelationProvider(), rightVisitor.getRelationProvider()); }
public static Predicate[] accessKeyListPredicates( CriteriaBuilder cb, Root<AccessKey> from, Long userId, Optional<String> labelOpt, Optional<String> labelPatten, Optional<Integer> typeOpt) { List<Predicate> predicates = new LinkedList<>(); Join user = (Join) from.fetch("user", JoinType.LEFT); predicates.add(cb.equal(user.get("id"), userId)); if (labelPatten.isPresent()) { labelPatten.ifPresent(pattern -> predicates.add(cb.like(from.get("label"), pattern))); } else { labelOpt.ifPresent(label -> predicates.add(cb.equal(from.get("label"), label))); } typeOpt.ifPresent(type -> predicates.add(cb.equal(from.get("type"), type))); return predicates.toArray(new Predicate[predicates.size()]); }
@SuppressWarnings("unchecked") protected SetJoin<UserEntity, ExtensionFieldValueEntity> createOrGetJoin( String alias, Root<UserEntity> root, SetAttribute<UserEntity, ExtensionFieldValueEntity> attribute) { for (Join<UserEntity, ?> currentJoin : root.getJoins()) { if (currentJoin.getAlias() == null) { // if alias is null, it is not an alias for an extension join, so we ignore it continue; } if (currentJoin.getAlias().equals(alias)) { return (SetJoin<UserEntity, ExtensionFieldValueEntity>) currentJoin; } } final SetJoin<UserEntity, ExtensionFieldValueEntity> join = root.join(attribute, JoinType.LEFT); join.alias(alias); return join; }
@SuppressWarnings("unchecked") private static List<Predicate> deviceSpecificPrincipalPredicates( CriteriaBuilder cb, Root<Device> from, Optional<HivePrincipal> principal) { final List<Predicate> predicates = new LinkedList<>(); final Join<Device, Network> networkJoin = (Join) from.fetch("network", JoinType.LEFT); final Join<Device, Network> usersJoin = (Join) networkJoin.fetch("users", JoinType.LEFT); from.fetch("deviceClass", JoinType.LEFT); // need this fetch to populate deviceClass principal.ifPresent( p -> { User user = p.getUser(); if (user == null && p.getKey() != null) { user = p.getKey().getUser(); } if (user != null && !user.isAdmin()) { predicates.add(cb.equal(usersJoin.<Long>get("id"), user.getId())); } if (p.getDevice() != null) { predicates.add(cb.equal(from.<Long>get("id"), p.getDevice().getId())); } if (p.getKey() != null) { for (AccessKeyBasedFilterForDevices extraFilter : AccessKeyBasedFilterForDevices.createExtraFilters(p.getKey().getPermissions())) { if (extraFilter.getDeviceGuids() != null) { predicates.add(from.<String>get("guid").in(extraFilter.getDeviceGuids())); } if (extraFilter.getNetworkIds() != null) { predicates.add(networkJoin.<Long>get("id").in(extraFilter.getNetworkIds())); } } } }); return predicates; }
Table resolveTable(int index) { int numTables = -1; for (int i = 0; i < getTableCount(); i++) { Object table = getTable(i); if (table instanceof Table) { numTables++; if (numTables == index) return (Table) table; } else if (table instanceof Join) { Object o = table; while (o instanceof Join) { Join join = (Join) o; o = join.getLeft(); if (o instanceof Table) { numTables++; if (numTables == index) return (Table) o; o = join.getRight(); } } numTables++; if (numTables == index) return (Table) o; } else throw new RuntimeException("unknown table type"); } throw new RuntimeException("can't resolve table"); }
/** Displays Lobby Screen. */ private void displayLobby() { // true MediumInput.setVisible(true); Start.setVisible(true); Cancel.setVisible(true); getServerName.setVisible(true); getIpNumber.setVisible(true); getPlayerNames.setVisible(true); // false gameErrors.setVisible(false); serversError.setVisible(false); back.setVisible(false); Credits.setVisible(false); Servers.setVisible(false); BigInput2.setVisible(false); LongInput.setVisible(false); LongInput2.setVisible(false); Join.setVisible(false); Create2.setVisible(false); ip.setVisible(false); serverName.setVisible(false); }
/** Displays Server Screen. */ private void displayServers() { // true back.setVisible(true); Servers.setVisible(true); BigInput2.setVisible(true); LongInput.setVisible(true); LongInput2.setVisible(true); Join.setVisible(true); Create2.setVisible(true); ip.setVisible(true); serverName.setVisible(true); serversError.setVisible(true); // false getServerName.setVisible(false); getIpNumber.setVisible(false); getPlayerNames.setVisible(false); loginCreate.setVisible(false); Credits.setVisible(false); Login.setVisible(false); Login2.setVisible(false); SmallInput.setVisible(false); SmallInput2.setVisible(false); SmallInput3.setVisible(false); SmallInput4.setVisible(false); SmallInput5.setVisible(false); CreateNewAccount.setVisible(false); Create.setVisible(false); MediumInput.setVisible(false); Start.setVisible(false); Cancel.setVisible(false); username.setVisible(false); password.setVisible(false); newUsername.setVisible(false); newPassword.setVisible(false); verifyPassword.setVisible(false); }
@Override public PhysicalOperator visitJoin(Join join, Object value) throws OptimizerException { PhysicalOperator leftOp = join.getLeft().accept(this, value); List<OrderDef> leftOrderDefs = Lists.newArrayList(); for (JoinCondition jc : join.getConditions()) { leftOrderDefs.add(new OrderDef(Direction.ASC, jc.getLeft())); } leftOp = new Sort(leftOp, leftOrderDefs, false); leftOp = new SelectionVectorRemover(leftOp); PhysicalOperator rightOp = join.getRight().accept(this, value); List<OrderDef> rightOrderDefs = Lists.newArrayList(); for (JoinCondition jc : join.getConditions()) { rightOrderDefs.add(new OrderDef(Direction.ASC, jc.getRight())); } rightOp = new Sort(rightOp, rightOrderDefs, false); rightOp = new SelectionVectorRemover(rightOp); MergeJoinPOP mjp = new MergeJoinPOP( leftOp, rightOp, Arrays.asList(join.getConditions()), join.getJointType()); return new SelectionVectorRemover(mjp); }
/** @brief The following functions override functions of the interfaces. */ public void visit(PlainSelect plainSelect) throws Exception { if (plainSelect.getFromItem() != null) { if (plainSelect.getFromItem().getAlias() != null) { this.aliasTableNameList.add(plainSelect.getFromItem().getAlias().getName()); } plainSelect.getFromItem().accept(this); } if (plainSelect.getJoins() != null) { for (Iterator joinsIt = plainSelect.getJoins().iterator(); joinsIt.hasNext(); ) { Join join = (Join) joinsIt.next(); if (join.getRightItem().getAlias() != null) { this.aliasTableNameList.add(join.getRightItem().getAlias().getName()); } if (join.getOnExpression() != null) { join.getOnExpression().accept(this); } join.getRightItem().accept(this); } } // Select selectItem From fromItem, joinItem Where whereClause. if (plainSelect.getSelectItems() != null) { for (SelectItem selectItem : plainSelect.getSelectItems()) { selectItem.accept(this); } } if (plainSelect.getWhere() != null) { plainSelect.getWhere().accept(this); } if (plainSelect.getGroupByColumnReferences() != null) { for (Iterator groupByIt = plainSelect.getGroupByColumnReferences().iterator(); groupByIt.hasNext(); ) { Expression groupBy = (Expression) groupByIt.next(); groupBy.accept(this); } } if (plainSelect.getClusterByElements() != null) { for (Iterator clusterByit = plainSelect.getClusterByElements().iterator(); clusterByit.hasNext(); ) { ClusterByElement clusterByElement = (ClusterByElement) clusterByit.next(); visit(clusterByElement); } } if (plainSelect.getDistributeByElements() != null) { for (Iterator distributeByIt = plainSelect.getDistributeByElements().iterator(); distributeByIt.hasNext(); ) { DistributeByElement distributeByElement = (DistributeByElement) distributeByIt.next(); visit(distributeByElement); } } if (plainSelect.getOrderByElements() != null) { for (Iterator orderByIt = plainSelect.getOrderByElements().iterator(); orderByIt.hasNext(); ) { OrderByElement orderByElement = (OrderByElement) orderByIt.next(); orderByElement.accept(this); } } if (plainSelect.getSortByElements() != null) { for (Iterator sortByIt = plainSelect.getSortByElements().iterator(); sortByIt.hasNext(); ) { SortByElement sortByElement = (SortByElement) sortByIt.next(); visit(sortByElement); } } if (plainSelect.getHaving() != null) { plainSelect.getHaving().accept(this); } }
/** * If statements to see if any labels are hoovered over. If so, the image is changed. If left, the * image is changed. */ public void mouseMoved(MouseEvent e) { if (layeredPane.findComponentAt(e.getX(), e.getY()) != NewgameText) { NewgameText.setIcon(new ImageIcon("img/New game text.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == NewgameText) { NewgameText.setIcon(new ImageIcon("img/newgameholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != InstructionsSmallText) { InstructionsSmallText.setIcon(new ImageIcon("img/instructionstext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == InstructionsSmallText) { InstructionsSmallText.setIcon(new ImageIcon("img/Instructionsholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != HighscoreText) { HighscoreText.setIcon(new ImageIcon("img/highscoretext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == HighscoreText) { HighscoreText.setIcon(new ImageIcon("img/highscoreholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != ExitGameText) { ExitGameText.setIcon(new ImageIcon("img/exit game.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == ExitGameText) { ExitGameText.setIcon(new ImageIcon("img/exit game holdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != back) { back.setIcon(new ImageIcon("img/back.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == back) { back.setIcon(new ImageIcon("img/backholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != PlayerVsComp) { PlayerVsComp.setIcon(new ImageIcon("img/playvscomptext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == PlayerVsComp) { PlayerVsComp.setIcon(new ImageIcon("img/playvscompholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != PlayerVsPlayer) { PlayerVsPlayer.setIcon(new ImageIcon("img/playervsplayertext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == PlayerVsPlayer) { PlayerVsPlayer.setIcon(new ImageIcon("img/playervsplayertextholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != TwoPlayerVsTwoPlayer) { TwoPlayerVsTwoPlayer.setIcon(new ImageIcon("img/2playervs2playertext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == TwoPlayerVsTwoPlayer) { TwoPlayerVsTwoPlayer.setIcon(new ImageIcon("img/2playervs2playertextholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Easy) { Easy.setIcon(new ImageIcon("img/easytext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Easy) { Easy.setIcon(new ImageIcon("img/easytextholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Medium) { Medium.setIcon(new ImageIcon("img/mediumtext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Medium) { Medium.setIcon(new ImageIcon("img/mediumtextholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Hard) { Hard.setIcon(new ImageIcon("img/hardtext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Hard) { Hard.setIcon(new ImageIcon("img/hardtextholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Online) { Online.setIcon(new ImageIcon("img/onlinetext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Online) { Online.setIcon(new ImageIcon("img/onlinetextholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Lan) { Lan.setIcon(new ImageIcon("img/lantext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Lan) { Lan.setIcon(new ImageIcon("img/lantextholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Login2) { Login2.setIcon(new ImageIcon("img/login.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Login2) { Login2.setIcon(new ImageIcon("img/loginholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Create) { Create.setIcon(new ImageIcon("img/create.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Create) { Create.setIcon(new ImageIcon("img/createholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Join) { Join.setIcon(new ImageIcon("img/join.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Join) { Join.setIcon(new ImageIcon("img/joinholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Create2) { Create2.setIcon(new ImageIcon("img/create.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Create2) { Create2.setIcon(new ImageIcon("img/createholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Start) { Start.setIcon(new ImageIcon("img/starttext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Start) { Start.setIcon(new ImageIcon("img/starttextholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Cancel) { Cancel.setIcon(new ImageIcon("img/cancel.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Cancel) { Cancel.setIcon(new ImageIcon("img/cancelholdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != returnToMain) { returnToMain.setIcon(new ImageIcon("img/return to main menu.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == returnToMain) { returnToMain.setIcon(new ImageIcon("img/return to main menu holdover.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != mainMenu) { mainMenu.setIcon(new ImageIcon("img/mainmenu.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == mainMenu) { mainMenu.setIcon(new ImageIcon("img/mainmenuholdover.png")); } displayCurrentScreen(); }
// If statements checking if any, and which label was clicked. Takes the // player another screen. public void mouseReleased(MouseEvent e) { if (layeredPane.findComponentAt(e.getX(), e.getY()) == NewgameText) { currentScreen = 2; if (dBg) System.out.println("New game screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != NewgameText) { NewgameText.setIcon(new ImageIcon("img/New game text.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == InstructionsSmallText) { currentScreen = 3; if (dBg) System.out.println("Instructions screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != InstructionsSmallText) { InstructionsSmallText.setIcon(new ImageIcon("img/instructionstext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == HighscoreText) { currentScreen = 4; if (dBg) System.out.println("Highscore screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != HighscoreText) { HighscoreText.setIcon(new ImageIcon("img/highscoretext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == ExitGameText) { currentScreen = 5; if (dBg) System.out.println("Game exits after 5seconds delay, and credit screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != ExitGameText) { ExitGameText.setIcon(new ImageIcon("img/exit game.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == PlayerVsComp) { currentScreen = 6; if (dBg) System.out.println("Difficulty screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != PlayerVsComp) { PlayerVsComp.setIcon(new ImageIcon("img/playvscomptext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == PlayerVsPlayer) { currentScreen = 7; if (dBg) System.out.println("Network Mode screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != PlayerVsPlayer) { PlayerVsPlayer.setIcon(new ImageIcon("img/playervsplayertext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == TwoPlayerVsTwoPlayer) { currentScreen = 7; if (dBg) System.out.println("Network Mode screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != TwoPlayerVsTwoPlayer) { TwoPlayerVsTwoPlayer.setIcon(new ImageIcon("img/2playervs2playertext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Easy) { if (dBg) System.out.println("game screen displayed"); currentScreen = 11; localGame = new LocalGame(this, 0); board1Label.setGame(localGame); board2Label.setGame(localGame); board1Label.setClickable(false); board2Label.setClickable(true); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Easy) { Easy.setIcon(new ImageIcon("img/easytext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Medium) { currentScreen = 11; localGame = new LocalGame(this, 1); board1Label.setGame(localGame); board2Label.setGame(localGame); board1Label.setClickable(false); board2Label.setClickable(true); if (dBg) System.out.println("game screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Medium) { Medium.setIcon(new ImageIcon("img/mediumtext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Hard) { localGame = new LocalGame(this, 2); board1Label.setGame(localGame); board2Label.setGame(localGame); board1Label.setClickable(false); board2Label.setClickable(true); currentScreen = 11; if (dBg) System.out.println("game screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Hard) { Hard.setIcon(new ImageIcon("img/hardtext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Online) { currentScreen = 8; // connect to the database loginCreate.setText("connecting..."); try { database = new Database("localhost", "battleship", "root", "rtpassword", ""); loginCreate.setText("Connected. Input your data."); } catch (Exception ex) { System.out.println("Unable to connect."); } if (dBg) System.out.println("Login screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Online) { Online.setIcon(new ImageIcon("img/onlinetext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Lan) { currentScreen = 8; if (dBg) System.out.println("Login screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Lan) { Lan.setIcon(new ImageIcon("img/lantext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Login2) { char[] passwordSequence = password.getPassword(); String userNameString = username.getText(); System.out.println("\n" + userNameString); for (int i = 0; i < passwordSequence.length; i++) System.out.print(passwordSequence[i]); String check = database.checkUser(username.getText(), new String(password.getPassword())); if (check == "OK") { currentScreen = 9; if (dBg) System.out.println("Server screen displayed"); } else { loginCreate.setText(check); } } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Login2) { Login2.setIcon(new ImageIcon("img/login.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Create) { char[] newPasswordSequence = newPassword.getPassword(); char[] verPassSequence = verifyPassword.getPassword(); String newUserNameString = newUsername.getText(); currentScreen = 9; if (dBg) System.out.println("Server screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Create) { Create.setIcon(new ImageIcon("img/create.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Join) { String ipString = ip.getText(); currentScreen = 10; if (dBg) System.out.println("Lobby screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Join) { Join.setIcon(new ImageIcon("img/join.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Create2) { String serverNameString = serverName.getText(); currentScreen = 10; if (dBg) System.out.println("Lobby screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Create2) { Create2.setIcon(new ImageIcon("img/create.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Start) { currentScreen = 11; if (dBg) System.out.println("Game screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Start) { Start.setIcon(new ImageIcon("img/starttext.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == Cancel) { currentScreen = 9; if (dBg) System.out.println("Server screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != Cancel) { Cancel.setIcon(new ImageIcon("img/cancel.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == returnToMain) { emptyArrays(); currentScreen = 1; if (dBg) System.out.println("start screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != returnToMain) { returnToMain.setIcon(new ImageIcon("img/return to main menu.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == mainMenu) { currentScreen = 1; if (dBg) System.out.println("start screen displayed"); } if (layeredPane.findComponentAt(e.getX(), e.getY()) != mainMenu) { mainMenu.setIcon(new ImageIcon("img/mainmenu.png")); } if (layeredPane.findComponentAt(e.getX(), e.getY()) == back) { switch (currentScreen) { case 2: currentScreen = 1; if (dBg) System.out.println("start screen displayed"); break; case 3: currentScreen = 1; if (dBg) System.out.println("start screen displayed"); break; case 4: currentScreen = 1; if (dBg) System.out.println("start screen displayed"); break; case 6: currentScreen = 2; if (dBg) System.out.println("New Game screen displayed"); break; case 7: currentScreen = 2; if (dBg) System.out.println("start screen displayed"); break; case 8: currentScreen = 7; if (dBg) System.out.println("Network mode screen displayed"); break; case 9: currentScreen = 8; if (dBg) System.out.println("Login screen displayed"); break; } } if (layeredPane.findComponentAt(e.getX(), e.getY()) != back) { back.setIcon(new ImageIcon("img/back.png")); } displayCurrentScreen(); }
@Override public StorageResults visit(Select select) { // TMDM-4654: Checks if entity has a composite PK. Set<ComplexTypeMetadata> compositeKeyTypes = new HashSet<ComplexTypeMetadata>(); // TMDM-7496: Search should include references to reused types Collection<ComplexTypeMetadata> types = new HashSet<ComplexTypeMetadata>(select.accept(new SearchTransitiveClosure())); for (ComplexTypeMetadata type : types) { if (type.getKeyFields().size() > 1) { compositeKeyTypes.add(type); } } if (!compositeKeyTypes.isEmpty()) { StringBuilder message = new StringBuilder(); Iterator it = compositeKeyTypes.iterator(); while (it.hasNext()) { ComplexTypeMetadata compositeKeyType = (ComplexTypeMetadata) it.next(); message.append(compositeKeyType.getName()); if (it.hasNext()) { message.append(','); } } throw new FullTextQueryCompositeKeyException(message.toString()); } // Removes Joins and joined fields. List<Join> joins = select.getJoins(); if (!joins.isEmpty()) { Set<ComplexTypeMetadata> joinedTypes = new HashSet<ComplexTypeMetadata>(); for (Join join : joins) { joinedTypes.add(join.getRightField().getFieldMetadata().getContainingType()); } for (ComplexTypeMetadata joinedType : joinedTypes) { types.remove(joinedType); } List<TypedExpression> filteredFields = new LinkedList<TypedExpression>(); for (TypedExpression expression : select.getSelectedFields()) { if (expression instanceof Field) { FieldMetadata fieldMetadata = ((Field) expression).getFieldMetadata(); if (joinedTypes.contains(fieldMetadata.getContainingType())) { TypeMapping mapping = mappings.getMappingFromDatabase(fieldMetadata.getContainingType()); filteredFields.add( new Alias( new StringConstant(StringUtils.EMPTY), mapping.getUser(fieldMetadata).getName())); } else { filteredFields.add(expression); } } else { filteredFields.add(expression); } } selectedFields.clear(); selectedFields.addAll(filteredFields); } // Handle condition Condition condition = select.getCondition(); if (condition == null) { throw new IllegalArgumentException("Expected a condition in select clause but got 0."); } // Create Lucene query (concatenates all sub queries together). FullTextSession fullTextSession = Search.getFullTextSession(session); Query parsedQuery = select.getCondition().accept(new LuceneQueryGenerator(types)); // Create Hibernate Search query Set<Class> classes = new HashSet<Class>(); for (ComplexTypeMetadata type : types) { String className = ClassCreator.getClassName(type.getName()); try { ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); classes.add(contextClassLoader.loadClass(className)); } catch (ClassNotFoundException e) { throw new RuntimeException("Could not find class '" + className + "'.", e); } } FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( parsedQuery, classes.toArray(new Class<?>[classes.size()])); // Very important to leave this null (would disable ability to search across different types) fullTextQuery.setCriteriaQuery(null); fullTextQuery.setSort(Sort.RELEVANCE); // Default sort (if no order by specified). query = EntityFinder.wrap( fullTextQuery, (HibernateStorage) storage, session); // ensures only MDM entity objects are returned. // Order by for (OrderBy current : select.getOrderBy()) { current.accept(this); } // Paging Paging paging = select.getPaging(); paging.accept(this); pageSize = paging.getLimit(); boolean hasPaging = pageSize < Integer.MAX_VALUE; if (!hasPaging) { return createResults(query.scroll(ScrollMode.FORWARD_ONLY)); } else { return createResults(query.list()); } }
@Override public SearchResult<VeteranAssessment> searchVeteranAssessment( Integer veteranAssessmentId, Integer veteranId, Integer programId, Integer clinicanId, Integer createdByUserId, Date fromAssessmentDate, Date toAssessmentDate, List<Integer> programIdList, SearchAttributes searchAttributes) { CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<VeteranAssessment> criteriaQuery = criteriaBuilder.createQuery(VeteranAssessment.class); Root<VeteranAssessment> veteranAssessmentRoot = criteriaQuery.from(VeteranAssessment.class); Join<VeteranAssessment, AssessmentStatus> assessmentStatusJoin = veteranAssessmentRoot.join("assessmentStatus"); Join<VeteranAssessment, Veteran> veteranJoin = veteranAssessmentRoot.join("veteran"); Join<VeteranAssessment, Program> programJoin = veteranAssessmentRoot.join("program"); Join<VeteranAssessment, User> clinicianJoin = veteranAssessmentRoot.join("clinician"); Join<VeteranAssessment, User> createdByUserJoin = veteranAssessmentRoot.join("createdByUser"); List<Predicate> criteriaList = new ArrayList<Predicate>(); if (veteranAssessmentId != null) { criteriaList.add( criteriaBuilder.equal( veteranAssessmentRoot.get("veteranAssessmentId"), veteranAssessmentId)); } if (veteranId != null) { criteriaList.add(criteriaBuilder.equal(veteranJoin.get("veteranId"), veteranId)); } if (programId != null) { criteriaList.add(criteriaBuilder.equal(programJoin.get("programId"), programId)); } if (clinicanId != null) { criteriaList.add(criteriaBuilder.equal(clinicianJoin.get("userId"), clinicanId)); } if (createdByUserId != null) { criteriaList.add(criteriaBuilder.equal(createdByUserJoin.get("userId"), createdByUserId)); } if (fromAssessmentDate != null) { criteriaList.add( criteriaBuilder.greaterThanOrEqualTo( veteranAssessmentRoot.<Date>get("dateUpdated"), fromAssessmentDate)); } if (toAssessmentDate != null) { criteriaList.add( criteriaBuilder.lessThanOrEqualTo( veteranAssessmentRoot.<Date>get("dateUpdated"), toAssessmentDate)); } if (programIdList != null && programIdList.size() > 0) { Expression<Integer> exp = programJoin.get("programId"); Predicate programIdPredicate = exp.in(programIdList); criteriaList.add(programIdPredicate); } criteriaQuery.select(veteranAssessmentRoot); criteriaQuery.where(criteriaBuilder.and(criteriaList.toArray(new Predicate[0]))); // Set default order by field and then check if one was passed to us. @SuppressWarnings("rawtypes") Expression orderByPath = veteranAssessmentRoot.get("veteranAssessmentId"); if (StringUtils.isNotBlank(searchAttributes.getSortColumn())) { if (searchAttributes.getSortColumn().equalsIgnoreCase("programName")) { orderByPath = programJoin.get("name"); } else if (searchAttributes.getSortColumn().equalsIgnoreCase("clinicianName")) { orderByPath = clinicianJoin.get("lastName"); } else if (searchAttributes.getSortColumn().equalsIgnoreCase("createdBy")) { orderByPath = createdByUserJoin.get("lastName"); } else if (searchAttributes.getSortColumn().equalsIgnoreCase("createDate")) { orderByPath = veteranAssessmentRoot.get("dateCreated"); } else if (searchAttributes.getSortColumn().equalsIgnoreCase("assessmentDate")) { orderByPath = veteranAssessmentRoot.get("dateUpdated"); } else if (searchAttributes.getSortColumn().equalsIgnoreCase("completeDate")) { orderByPath = veteranAssessmentRoot.get("dateCompleted"); } else if (searchAttributes.getSortColumn().equalsIgnoreCase("veteranId")) { orderByPath = veteranJoin.get("veteranId"); } else if (searchAttributes.getSortColumn().equalsIgnoreCase("veteranName")) { orderByPath = veteranJoin.get("lastName"); } else if (searchAttributes.getSortColumn().equalsIgnoreCase("assessmentStatusName")) { orderByPath = assessmentStatusJoin.get("name"); } else if (searchAttributes.getSortColumn().equalsIgnoreCase("ssnLastFour")) { orderByPath = veteranJoin.get("ssnLastFour"); } else if (searchAttributes.getSortColumn().equalsIgnoreCase("duration")) { orderByPath = veteranAssessmentRoot.get("duration"); } else if (searchAttributes.getSortColumn().equalsIgnoreCase("percentComplete")) { orderByPath = veteranAssessmentRoot.get("percentComplete"); } } if (searchAttributes.getSortDirection() == SortDirection.SORT_DESCENDING) { criteriaQuery.orderBy(criteriaBuilder.desc(orderByPath)); } else { criteriaQuery.orderBy(criteriaBuilder.asc(orderByPath)); } // Generate the query based on the criteria. TypedQuery<VeteranAssessment> query = entityManager.createQuery(criteriaQuery); SearchResult<VeteranAssessment> searchResult = new SearchResult<VeteranAssessment>(); // Get the total count. Not a very efficient way.... Integer totalCount = query.getResultList().size(); searchResult.setTotalNumRowsFound(totalCount); // Now get only the page. query.setFirstResult(searchAttributes.getRowStartIndex()); query.setMaxResults(searchAttributes.getPageSize()); List<VeteranAssessment> veteranAssessments = query.getResultList(); searchResult.setResultList(veteranAssessments); return searchResult; }
@Override public List<VeteranAssessment> searchVeteranAssessmentForExport( Integer clinicanId, Integer createdByUserId, Integer programId, Date fromAssessmentDate, Date toAssessmentDate, Integer veteranId, List<Integer> programIdList) { CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<VeteranAssessment> criteriaQuery = criteriaBuilder.createQuery(VeteranAssessment.class); Root<VeteranAssessment> veteranAssessmentRoot = criteriaQuery.from(VeteranAssessment.class); Join<VeteranAssessment, AssessmentStatus> assessmentStatusJoin = veteranAssessmentRoot.join("assessmentStatus"); List<Predicate> criteriaList = new ArrayList<Predicate>(); // only include assessments in the appropriate state Expression<Integer> statusExp = assessmentStatusJoin.get("assessmentStatusId"); Predicate statusPredicate = statusExp.in(getExportAssessmentStates()); criteriaList.add(statusPredicate); if (clinicanId != null) { Join<VeteranAssessment, User> clinicianJoin = veteranAssessmentRoot.join("clinician"); criteriaList.add(criteriaBuilder.equal(clinicianJoin.get("userId"), clinicanId)); } if (createdByUserId != null) { Join<VeteranAssessment, User> createdByUserJoin = veteranAssessmentRoot.join("createdByUser"); criteriaList.add(criteriaBuilder.equal(createdByUserJoin.get("userId"), createdByUserId)); } if (fromAssessmentDate != null) { criteriaList.add( criteriaBuilder.greaterThan( veteranAssessmentRoot.<Date>get("dateCreated"), fromAssessmentDate)); } if (toAssessmentDate != null) { criteriaList.add( criteriaBuilder.lessThanOrEqualTo( veteranAssessmentRoot.<Date>get("dateCreated"), toAssessmentDate)); } if (veteranId != null) { Join<VeteranAssessment, Veteran> veteranJoin = veteranAssessmentRoot.join("veteran"); criteriaList.add(criteriaBuilder.equal(veteranJoin.get("veteranId"), veteranId)); } if (programId != null) { // criteriaList.add(criteriaBuilder.equal(programJoin.get("programId"), programId)); if (programIdList == null) { programIdList = new ArrayList<Integer>(); } programIdList.add(programId); } if (programIdList != null && programIdList.size() > 0) { Join<VeteranAssessment, Program> programJoin = veteranAssessmentRoot.join("program"); Expression<Integer> exp = programJoin.get("programId"); Predicate programIdPredicate = exp.in(programIdList); criteriaList.add(programIdPredicate); } criteriaQuery.select(veteranAssessmentRoot); criteriaQuery.where(criteriaBuilder.and(criteriaList.toArray(new Predicate[0]))); @SuppressWarnings("rawtypes") Expression orderByPath = veteranAssessmentRoot.get("veteranAssessmentId"); criteriaQuery.orderBy(criteriaBuilder.desc(orderByPath)); // Generate the query based on the criteria. TypedQuery<VeteranAssessment> query = entityManager.createQuery(criteriaQuery); List<VeteranAssessment> veteranAssessments = query.getResultList(); return veteranAssessments; }
@Override protected void addPackageVersion(Join fromJoin) { addCondition(DBSchema.C_ENTITY_PACKAGE_VERSION, fromJoin.getPackageVersion()); }
public long getCardinality(Join join, BindingSet bindings) { long card1 = getCardinality(join.getLeftArg(), bindings); long card2 = getCardinality(join.getRightArg(), bindings); double sel = 0.5; return (long) (card1 * card2 * sel); }
private SubTreeDescriptor buildTree( final int queryPlanDepth, final int currentDepth, final DbIterator queryPlan, final int currentStartPosition, final int parentUpperBarStartShift) { if (queryPlan == null) return null; int adjustDepth = currentDepth == 0 ? -1 : 0; SubTreeDescriptor thisNode = new SubTreeDescriptor(null, null); if (queryPlan instanceof SeqScan) { SeqScan s = (SeqScan) queryPlan; String tableName = s.getTableName(); String alias = s.getAlias(); // TupleDesc td = s.getTupleDesc(); if (!tableName.equals(alias)) alias = " " + alias; else alias = ""; thisNode.text = String.format("%1$s(%2$s)", SCAN, tableName + alias); if (SCAN.length() / 2 < parentUpperBarStartShift) { thisNode.upBarPosition = currentStartPosition + parentUpperBarStartShift; thisNode.textStartPosition = thisNode.upBarPosition - SCAN.length() / 2; } else { thisNode.upBarPosition = currentStartPosition + SCAN.length() / 2; thisNode.textStartPosition = currentStartPosition; } thisNode.width = thisNode.textStartPosition - currentStartPosition + thisNode.text.length(); int embedHeight = (queryPlanDepth - currentDepth) / 2 - 1; thisNode.height = currentDepth + 2 * embedHeight; int currentHeight = thisNode.height; SubTreeDescriptor parentNode = thisNode; for (int i = 0; i < embedHeight; i++) { parentNode = new SubTreeDescriptor(parentNode, null); parentNode.text = "|"; parentNode.upBarPosition = thisNode.upBarPosition; parentNode.width = thisNode.width; parentNode.height = currentHeight - 2; parentNode.textStartPosition = thisNode.upBarPosition; currentHeight -= 2; } thisNode = parentNode; } else { Operator plan = (Operator) queryPlan; DbIterator[] children = plan.getChildren(); if (plan instanceof Join) { Join j = (Join) plan; TupleDesc td = j.getTupleDesc(); JoinPredicate jp = j.getJoinPredicate(); String field1 = td.getFieldName(jp.getField1()); String field2 = td.getFieldName(jp.getField2() + children[0].getTupleDesc().numFields()); thisNode.text = String.format( "%1$s(%2$s),card:%3$d", JOIN, field1 + jp.getOperator() + field2, j.getEstimatedCardinality()); int upBarShift = parentUpperBarStartShift; if (JOIN.length() / 2 > parentUpperBarStartShift) upBarShift = JOIN.length() / 2; SubTreeDescriptor left = buildTree( queryPlanDepth, currentDepth + adjustDepth + 3, children[0], currentStartPosition, upBarShift); SubTreeDescriptor right = buildTree( queryPlanDepth, currentDepth + adjustDepth + 3, children[1], currentStartPosition + left.width + SPACE.length(), 0); thisNode.upBarPosition = (left.upBarPosition + right.upBarPosition) / 2; thisNode.textStartPosition = thisNode.upBarPosition - JOIN.length() / 2; thisNode.width = Math.max( left.width + right.width + SPACE.length(), thisNode.textStartPosition + thisNode.text.length() - currentStartPosition); thisNode.leftChild = left; thisNode.rightChild = right; thisNode.height = currentDepth; } else if (plan instanceof HashEquiJoin) { HashEquiJoin j = (HashEquiJoin) plan; JoinPredicate jp = j.getJoinPredicate(); TupleDesc td = j.getTupleDesc(); String field1 = td.getFieldName(jp.getField1()); String field2 = td.getFieldName(jp.getField2() + children[0].getTupleDesc().numFields()); thisNode.text = String.format( "%1$s(%2$s),card:%3$d", HASH_JOIN, field1 + jp.getOperator() + field2, j.getEstimatedCardinality()); int upBarShift = parentUpperBarStartShift; if (HASH_JOIN.length() / 2 > parentUpperBarStartShift) upBarShift = HASH_JOIN.length() / 2; SubTreeDescriptor left = buildTree( queryPlanDepth, currentDepth + 3 + adjustDepth, children[0], currentStartPosition, upBarShift); SubTreeDescriptor right = buildTree( queryPlanDepth, currentDepth + 3 + adjustDepth, children[1], currentStartPosition + left.width + SPACE.length(), 0); thisNode.upBarPosition = (left.upBarPosition + right.upBarPosition) / 2; thisNode.textStartPosition = thisNode.upBarPosition - HASH_JOIN.length() / 2; thisNode.width = Math.max( left.width + right.width + SPACE.length(), thisNode.textStartPosition + thisNode.text.length() - currentStartPosition); thisNode.leftChild = left; thisNode.rightChild = right; thisNode.height = currentDepth; } else if (plan instanceof Aggregate) { Aggregate a = (Aggregate) plan; int upBarShift = parentUpperBarStartShift; String alignTxt; TupleDesc td = a.getTupleDesc(); int gfield = a.groupField(); if (gfield == Aggregator.NO_GROUPING) { thisNode.text = String.format( "%1$s(%2$s),card:%3$d", a.aggregateOp(), a.aggregateFieldName(), a.getEstimatedCardinality()); alignTxt = td.getFieldName(00); } else { thisNode.text = String.format( "%1$s(%2$s), %3$s(%4$s),card:%5$d", GROUPBY, a.groupFieldName(), a.aggregateOp(), a.aggregateFieldName(), a.getEstimatedCardinality()); alignTxt = GROUPBY; } if (alignTxt.length() / 2 > parentUpperBarStartShift) upBarShift = alignTxt.length() / 2; SubTreeDescriptor child = buildTree( queryPlanDepth, currentDepth + 2 + adjustDepth, children[0], currentStartPosition, upBarShift); thisNode.upBarPosition = child.upBarPosition; thisNode.textStartPosition = thisNode.upBarPosition - alignTxt.length() / 2; thisNode.width = Math.max( child.width, thisNode.textStartPosition + thisNode.text.length() - currentStartPosition); thisNode.leftChild = child; thisNode.height = currentDepth; } else if (plan instanceof Filter) { Filter f = (Filter) plan; Predicate p = f.getPredicate(); thisNode.text = String.format( "%1$s(%2$s),card:%3$d", SELECT, children[0].getTupleDesc().getFieldName(p.getField()) + p.getOp() + p.getOperand(), f.getEstimatedCardinality()); int upBarShift = parentUpperBarStartShift; if (SELECT.length() / 2 > parentUpperBarStartShift) upBarShift = SELECT.length() / 2; SubTreeDescriptor child = buildTree( queryPlanDepth, currentDepth + 2 + adjustDepth, children[0], currentStartPosition, upBarShift); thisNode.upBarPosition = child.upBarPosition; thisNode.textStartPosition = thisNode.upBarPosition - SELECT.length() / 2; thisNode.width = Math.max( child.width, thisNode.textStartPosition + thisNode.text.length() - currentStartPosition); thisNode.leftChild = child; thisNode.height = currentDepth; } else if (plan instanceof OrderBy) { OrderBy o = (OrderBy) plan; thisNode.text = String.format( "%1$s(%2$s),card:%3$d", ORDERBY, children[0].getTupleDesc().getFieldName(o.getOrderByField()), o.getEstimatedCardinality()); int upBarShift = parentUpperBarStartShift; if (ORDERBY.length() / 2 > parentUpperBarStartShift) upBarShift = ORDERBY.length() / 2; SubTreeDescriptor child = buildTree( queryPlanDepth, currentDepth + 2 + adjustDepth, children[0], currentStartPosition, upBarShift); thisNode.upBarPosition = child.upBarPosition; thisNode.textStartPosition = thisNode.upBarPosition - ORDERBY.length() / 2; thisNode.width = Math.max( child.width, thisNode.textStartPosition + thisNode.text.length() - currentStartPosition); thisNode.leftChild = child; thisNode.height = currentDepth; } else if (plan instanceof Project) { Project p = (Project) plan; String fields = ""; Iterator<TDItem> it = p.getTupleDesc().iterator(); while (it.hasNext()) fields += it.next().fieldName + ","; fields = fields.substring(0, fields.length() - 1); thisNode.text = String.format("%1$s(%2$s),card:%3$d", PROJECT, fields, p.getEstimatedCardinality()); int upBarShift = parentUpperBarStartShift; if (PROJECT.length() / 2 > parentUpperBarStartShift) upBarShift = PROJECT.length() / 2; SubTreeDescriptor child = buildTree( queryPlanDepth, currentDepth + 2 + adjustDepth, children[0], currentStartPosition, upBarShift); thisNode.upBarPosition = child.upBarPosition; thisNode.textStartPosition = thisNode.upBarPosition - PROJECT.length() / 2; thisNode.width = Math.max( child.width, thisNode.textStartPosition + thisNode.text.length() - currentStartPosition); thisNode.leftChild = child; thisNode.height = currentDepth; } else if (plan.getClass() .getSuperclass() .getSuperclass() .getSimpleName() .equals("Exchange")) { String name = "Exchange"; int card = 0; try { name = (String) plan.getClass().getMethod("getName").invoke(plan); card = (Integer) plan.getClass().getMethod("getEstimatedCardinality").invoke(plan); } catch (Exception e) { e.printStackTrace(); } thisNode.text = String.format("%1$s,card:%2$d", name, card); int upBarShift = parentUpperBarStartShift; if (name.length() / 2 > parentUpperBarStartShift) upBarShift = name.length() / 2; SubTreeDescriptor child = buildTree( queryPlanDepth, currentDepth + 2 + adjustDepth, children[0], currentStartPosition, upBarShift); if (child == null) { thisNode.upBarPosition = upBarShift; thisNode.textStartPosition = thisNode.upBarPosition - name.length() / 2; thisNode.width = thisNode.textStartPosition + thisNode.text.length() - currentStartPosition; } else { thisNode.upBarPosition = child.upBarPosition; thisNode.textStartPosition = thisNode.upBarPosition - name.length() / 2; thisNode.width = Math.max( child.width, thisNode.textStartPosition + thisNode.text.length() - currentStartPosition); thisNode.leftChild = child; } thisNode.height = currentDepth; } else if (plan.getClass().getName().equals("simpledb.Rename")) { String newName = null; int fieldIdx = 0; try { newName = (String) plan.getClass().getMethod("newName", (Class<?>[]) null).invoke(plan); fieldIdx = (Integer) plan.getClass().getMethod("renamedField", (Class<?>[]) null).invoke(plan); } catch (Exception e) { e.printStackTrace(); } String oldName = plan.getChildren()[0].getTupleDesc().getFieldName(fieldIdx); thisNode.text = String.format( "%1$s,%2$s->%3$s,card:%4$d", RENAME, oldName, newName, plan.getEstimatedCardinality()); int upBarShift = parentUpperBarStartShift; if (RENAME.length() / 2 > parentUpperBarStartShift) upBarShift = RENAME.length() / 2; SubTreeDescriptor child = buildTree( queryPlanDepth, currentDepth + 2 + adjustDepth, children[0], currentStartPosition, upBarShift); if (child == null) { thisNode.upBarPosition = upBarShift; thisNode.textStartPosition = thisNode.upBarPosition - RENAME.length() / 2; thisNode.width = thisNode.textStartPosition + thisNode.text.length() - currentStartPosition; } else { thisNode.upBarPosition = child.upBarPosition; thisNode.textStartPosition = thisNode.upBarPosition - RENAME.length() / 2; thisNode.width = Math.max( child.width, thisNode.textStartPosition + thisNode.text.length() - currentStartPosition); thisNode.leftChild = child; } thisNode.height = currentDepth; } } return thisNode; }