Code to display a Menu.
Skip Nav menu for reports.
@exception DBException File exception.
503524
public void printHtmlNavMenu(PrintWriter out)
        throws DBException
    {
        String strForms = this.getProperty(HtmlConstants.FORMS);                // Html page
        if (strForms != null) if (strForms.equalsIgnoreCase(HtmlConstants.DISPLAY))
            ((BasePanel)this.getScreenField()).setProperty(DBParams.NAVMENUS, UserInfoModel.NO_ICONS);   // Don't display NAV menus
//x            return;   // Don't display NAV menus
        super.printHtmlNavMenu(out);
    }
994801
public void printHtmlMenuStart(PrintWriter out, ResourceBundle reg)
        throws DBException
    {
        this.printHtmlBanner(out, reg);
        this.printHtmlLogo(out, reg);
        this.printHtmlMenubar(out, reg);

        String strHTML = reg.getString("htmlTableStart");
        strHTML = Utility.replaceResources(strHTML, reg, null, null);
        if ((strHTML == null) || (strHTML.length() == 0))
            strHTML = "<table border=\"0\" cellspacing=\"10\" width=\"100%\">\n<tr>";
        out.println(strHTML);

        this.printHtmlNavMenu(out);

        strHTML = reg.getString("htmlContentStart");
        if ((strHTML == null) || (strHTML.length() == 0))
            strHTML = "<td valign=\"top\">";
        out.println(strHTML);
    }
120986
public void displayDialog() throws IOException, ServletException {

        getSettings().setExplorerMode(CmsExplorer.VIEW_LIST);
        Map<String, String[]> addParams = new HashMap<String, String[]>();
        HttpServletRequest req = getJsp().getRequest();
        String addParamsVal = req.getParameter(CmsExplorer.PARAMETER_CONTEXTMENUPARAMS);
        if (addParamsVal != null) {
            addParams.put(CmsExplorer.PARAMETER_CONTEXTMENUPARAMS, new String[] {addParamsVal});
        }
        getToolManager().jspForwardPage(this, FILE_EXPLORER_FILELIST, addParams);
    }
537753
public void copyMenuHelp()
    {
        Record recClassInfo = this.getMainRecord();
        recClassInfo.setKeyArea(ClassInfo.CLASS_NAME_KEY);
        
        Record recMenus = this.getRecord(Menus.MENUS_FILE);

        try   {
            recMenus.setKeyArea(ClassInfo.ID_KEY);
            recMenus.close();
            while (recMenus.hasNext())
            {
                recMenus.next();
                if (recMenus.getField(Menus.AUTO_DESC).getState())
                {
                    String strClassReference = recMenus.getField(Menus.PROGRAM).toString();
                    String strClassType = recMenus.getField(Menus.TYPE).toString();
                    if ((strClassReference != null) && (strClassReference.length() > 0))
                        if (!strClassType.equalsIgnoreCase("menu"))
                    {
                        if (strClassReference.indexOf('.') != -1)
                            strClassReference = strClassReference.substring(strClassReference.lastIndexOf('.') + 1);
                        recClassInfo.getField(ClassInfo.CLASS_NAME).setString(strClassReference);
                        if (recClassInfo.seek(null))
                        {
                            recMenus.edit();
                            if (!recClassInfo.getField(ClassInfo.CLASS_DESC).isNull())
                                recMenus.getField(Menus.NAME).moveFieldToThis(recClassInfo.getField(ClassInfo.CLASS_DESC));
                            recMenus.getField(Menus.COMMENT).moveFieldToThis(recClassInfo.getField(ClassInfo.CLASS_EXPLAIN));
                            recMenus.set();
                        }
                    }
                }
            }
        } catch (DBException ex)    {
            ex.printStackTrace();
        }
    }
1233827
public void actionPerformed(ActionEvent ev) {

        String s = ev.getActionCommand();

        if (s == null) {
            if (ev.getSource() instanceof MenuItem) {
                MenuItem i;

                s = ((MenuItem) ev.getSource()).getLabel();
            }
        }

        if (s.equals("Execute")) {
            execute();
            layoutCard.show(pCard, "result");
        } else if (s.equals("Tree")) {
            layoutCard.show(pCard, "tree");
        } else if (s.equals("Command")) {
            layoutCard.show(pCard, "command");
        } else if (s.equals("Result")) {
            layoutCard.show(pCard, "result");
        } else if (s.equals("Editor")) {
            layoutCard.show(pCard, "editor");
        } else if (s.equals("Exit")) {
            windowClosing(null);
        } else if (s.equals("Logging on")) {
            JavaSystem.setLogToSystem(true);
        } else if (s.equals("Logging off")) {
            JavaSystem.setLogToSystem(false);
        } else if (s.equals("Refresh Tree")) {
            refreshTree();
            layoutCard.show(pCard, "tree");
        } else if (s.startsWith("#")) {
            int i = Integer.parseInt(s.substring(1));

            txtCommand.setText(sRecent[i]);
        } else if (s.equals("Connect...")) {
            connect(ZaurusConnectionDialog.createConnection(fMain, "Connect",
                    new Insets(defWidth, defHeight, defLocX, defLocY)));
            refreshTree();
            layoutCard.show(pCard, "tree");
        } else if (s.equals("View Tree")) {
            layoutCard.show(pCard, "tree");
        } else if (s.equals("View Command")) {
            layoutCard.show(pCard, "command");
        } else if (s.equals("View Result")) {
            layoutCard.show(pCard, "result");
        } else if (s.equals("View Editor")) {
            layoutCard.show(pCard, "editor");
        } else if (s.equals("Results in Grid")) {
            iResult = 0;

            pResult.removeAll();
            pResult.add("Center", gResult);
            pResult.doLayout();
            layoutCard.show(pCard, "result");
        } else if (s.equals("Open Script...")) {
            FileDialog f = new FileDialog(fMain, "Open Script",
                                          FileDialog.LOAD);

            // (ulrivo): set default directory if set from command line
            if (defDirectory != null) {
                f.setDirectory(defDirectory);
            }

            f.show();

            String file = f.getFile();

            if (file != null) {
                txtCommand.setText(
                    DatabaseManagerCommon.readFile(f.getDirectory() + file));
            }

            layoutCard.show(pCard, "command");
        } else if (s.equals("Save Script...")) {
            FileDialog f = new FileDialog(fMain, "Save Script",
                                          FileDialog.SAVE);

            // (ulrivo): set default directory if set from command line
            if (defDirectory != null) {
                f.setDirectory(defDirectory);
            }

            f.show();

            String file = f.getFile();

            if (file != null) {
                DatabaseManagerCommon.writeFile(f.getDirectory() + file,
                                                txtCommand.getText());
            }
        } else if (s.equals("Save Result...")) {
            FileDialog f = new FileDialog(fMain, "Save Result",
                                          FileDialog.SAVE);

            // (ulrivo): set default directory if set from command line
            if (defDirectory != null) {
                f.setDirectory(defDirectory);
            }

            f.show();

            String file = f.getFile();

            if (file != null) {
                showResultInText();
                DatabaseManagerCommon.writeFile(f.getDirectory() + file,
                                                txtResult.getText());
            }
        } else if (s.equals("Results in Text")) {
            iResult = 1;

            pResult.removeAll();
            pResult.add("Center", txtResult);
            pResult.doLayout();
            showResultInText();
            layoutCard.show(pCard, "result");
        } else if (s.equals("AutoCommit on")) {
            try {
                cConn.setAutoCommit(true);
            } catch (SQLException e) {}
        } else if (s.equals("AutoCommit off")) {
            try {
                cConn.setAutoCommit(false);
            } catch (SQLException e) {}
        } else if (s.equals("Commit")) {
            try {
                cConn.commit();
            } catch (SQLException e) {}
        } else if (s.equals("Insert test data")) {
            insertTestData();
            layoutCard.show(pCard, "result");
        } else if (s.equals("Rollback")) {
            try {
                cConn.rollback();
            } catch (SQLException e) {}
        } else if (s.equals("Disable MaxRows")) {
            try {
                sStatement.setMaxRows(0);
            } catch (SQLException e) {}
        } else if (s.equals("Set MaxRows to 100")) {
            try {
                sStatement.setMaxRows(100);
            } catch (SQLException e) {}
        } else if (s.equals("SELECT")) {
            showHelp(DatabaseManagerCommon.selectHelp);
        } else if (s.equals("INSERT")) {
            showHelp(DatabaseManagerCommon.insertHelp);
        } else if (s.equals("UPDATE")) {
            showHelp(DatabaseManagerCommon.updateHelp);
        } else if (s.equals("DELETE")) {
            showHelp(DatabaseManagerCommon.deleteHelp);
        } else if (s.equals("CREATE TABLE")) {
            showHelp(DatabaseManagerCommon.createTableHelp);
        } else if (s.equals("DROP TABLE")) {
            showHelp(DatabaseManagerCommon.dropTableHelp);
        } else if (s.equals("CREATE INDEX")) {
            showHelp(DatabaseManagerCommon.createIndexHelp);
        } else if (s.equals("DROP INDEX")) {
            showHelp(DatabaseManagerCommon.dropIndexHelp);
        } else if (s.equals("CHECKPOINT")) {
            showHelp(DatabaseManagerCommon.checkpointHelp);
        } else if (s.equals("SCRIPT")) {
            showHelp(DatabaseManagerCommon.scriptHelp);
        } else if (s.equals("SHUTDOWN")) {
            showHelp(DatabaseManagerCommon.shutdownHelp);
        } else if (s.equals("SET")) {
            showHelp(DatabaseManagerCommon.setHelp);
        } else if (s.equals("Test Script")) {
            showHelp(DatabaseManagerCommon.testHelp);
        } else if (s.equals("Show HTML-Help in browser")) {
            try {
                System.out.println("Starting Opera on index.html");
                Runtime.getRuntime().exec(new String[] {
                    "opera", "/home/QtPalmtop/help/html/hsqldb/index.html"
                });
            } catch (IOException e) {
                System.out.println("A problem with Opera occured.");
            }
        }
    }
439350
public static DatabaseException toDatabaseException(Exception ex)
    {
        if (ex instanceof DatabaseException)
            return (DatabaseException)ex;
        int iErrorCode = DBConstants.ERROR_STRING;
        if (ex instanceof DBException)
            iErrorCode = ((DBException)ex).getErrorCode();
        String strMessage = ex.getMessage();
        if (strMessage != null)
            if (strMessage.startsWith(DBEXCEPTION_TEXT))
        {
            int iNextPos = strMessage.indexOf(' ', DBEXCEPTION_TEXT.length());
            if (iNextPos != -1)
            {
                iErrorCode = Integer.parseInt(strMessage.substring(DBEXCEPTION_TEXT.length(), iNextPos));
                if (iNextPos + 1 < strMessage.length())
                    strMessage = strMessage.substring(iNextPos + 1);
            }
        }
        return new DatabaseException(iErrorCode, strMessage);
    }
486000
private void menuExecuteBodyActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_menuExecuteBodyActionPerformed
		SQLPPTriplesMap mapping = mappingList.getSelectedValue();
		if (mapping == null) {
			return;
		}
		final String sqlQuery = mapping.getSourceQuery().toString();

		SQLQueryPanel pnlQueryResult = new SQLQueryPanel(selectedSource, sqlQuery);

		JDialog dlgQueryResult = new JDialog();
		DialogUtils.installEscapeCloseOperation(dlgQueryResult);
		dlgQueryResult.setContentPane(pnlQueryResult);
		dlgQueryResult.pack();
		dlgQueryResult.setLocationRelativeTo(this);
		dlgQueryResult.setVisible(true);
		dlgQueryResult.setTitle("SQL Query Result");
	}
1224698
public void printHtmlNavMenu(PrintWriter out)
        throws DBException
    {
        String strHTML = null, strStart = null, strEnd = null;
        ResourceBundle reg = ((BaseApplication)this.getTask().getApplication()).getResources(HtmlConstants.HTML_RESOURCE, false);

        char ch = HBasePanel.getFirstToUpper(this.getProperty(DBParams.NAVMENUS), ' ');
        if (ch != UserInfoModel.NO_ICONS.charAt(0))
        {
            String strMenu = this.getProperty(DBParams.MENU); // This user's nav menu
            if ((strMenu == null) || (strMenu.length() == 0))
                strMenu = "NavMenu";
            if (ch == UserInfoModel.ICONS_ONLY.charAt(0))  /** Icons only */
            {
                strStart = reg.getString("htmlNavIconsOnlyStart");
                strHTML = reg.getString(strMenu + "IconsOnly");
                if ((strHTML == null) || (strHTML.length() == 0))
                    strHTML = reg.getString("htmlNavMenuIconsOnly");
                strEnd = reg.getString("htmlNavIconsOnlyEnd");
            }
            if ((strHTML == null) || (strHTML.length() == 0))
                strHTML = reg.getString(strMenu);
            if ((strHTML == null) || (strHTML.length() == 0))
                strHTML = reg.getString("htmlNavMenu");
                
            if ((strStart == null) || (strStart.length() == 0))
                strStart = reg.getString("htmlNavStart");
            if ((strEnd == null) || (strEnd.length() == 0))
                strEnd = reg.getString("htmlNavEnd");
        }
        if ((strHTML == null) || (strHTML.length() == 0) || 
            (strStart == null) || (strStart.length() == 0) || 
                (strEnd == null) || (strEnd.length() == 0))
        {
            strStart = Constants.BLANK;
            strHTML = Constants.BLANK;  // "\t<tr valign=top>\n\t<td>";  // Default menu = no table items
            strEnd = Constants.BLANK;
        }
        out.println(strStart);
        out.println(strHTML);
        out.println(strEnd);
    }
856646
public void actionShow() throws Exception {

        // try to load the historical resource
        if (CmsStringUtil.isNotEmpty(getParamVersion())) {
            showHistoricVersion();
        } else {
            String resourceStr = getParamResource();
            // trying to read the resource
            CmsResource resource = readResource(resourceStr);
            if (isDeleted(resource)) {
                // resource has been deleted in offline project
                throw new CmsVfsResourceNotFoundException(Messages.get().container(
                    Messages.ERR_RESOURCE_DELETED_2,
                    resourceStr,
                    getCms().getRequestContext().getCurrentProject().getName()));
            }

            // check for release / expiration time window
            autoTimeWarp(resource);

            // code for display resource after all tests for displayability (exists, not deleted)
            //            if (CmsResourceTypeXmlContainerPage.isContainerPage(resource)) {
            //                // if we have a container page look for the first sitemap entry
            //                // and use that to display the container page
            //                List<CmsInternalSitemapEntry> entries = OpenCms.getSitemapManager().getEntriesForStructureId(
            //                    getJsp().getCmsObject(),
            //                    resource.getStructureId());
            //                if (!entries.isEmpty()) {
            //                    CmsInternalSitemapEntry entry = entries.get(0);
            //                    resourceStr = entry.getRootPath();
            //                }
            //            }
            if (OpenCms.getSiteManager().isSharedFolder(getCms().getRequestContext().getSiteRoot())) {
                if (!OpenCms.getSiteManager().startsWithShared(resourceStr)) {
                    resourceStr = CmsStringUtil.joinPaths(OpenCms.getSiteManager().getSharedFolder(), resourceStr);
                }
            }
            String url = getJsp().link(resourceStr);
            // if in online project
            if ((url.indexOf("://") < 0) && getCms().getRequestContext().getCurrentProject().isOnlineProject()) {
                url = prependSiteRoot(url);
            }
            getJsp().getResponse().sendRedirect(url);
        }
    }
1079420
public void printMetadata() throws Exception {

        log.info("-----------------");
        log.info("RAFT Log Metadata");
        log.info("-----------------");

        byte[] firstAppendedBytes = db.get(FIRSTAPPENDED);
        log.info("First Appended: %d", fromByteArrayToInt(firstAppendedBytes));
        byte[] lastAppendedBytes = db.get(LASTAPPENDED);
        log.info("Last Appended: %d", fromByteArrayToInt(lastAppendedBytes));
        byte[] currentTermBytes = db.get(CURRENTTERM);
        log.info("Current Term: %d", fromByteArrayToInt(currentTermBytes));
        byte[] commitIndexBytes = db.get(COMMITINDEX);
        log.info("Commit Index: %d", fromByteArrayToInt(commitIndexBytes));
        Address votedForTmp =Util.objectFromByteBuffer(db.get(VOTEDFOR));
        log.info("Voted for: %s", votedForTmp);
    }
927417
public int getPrintOptions()
        throws DBException
    {
        int iHtmlOptions = super.getPrintOptions();
        if (this.getProperty(DBParams.XML) != null)
        {
            iHtmlOptions = iHtmlOptions & ~HtmlConstants.PRINT_TOOLBAR_BEFORE;  // No
            iHtmlOptions = iHtmlOptions & ~HtmlConstants.DONT_PRINT_SCREEN;     // Yes (look > this says DONT)
            iHtmlOptions = iHtmlOptions & ~HtmlConstants.PRINT_TOOLBAR_AFTER;  // No
        }
        return iHtmlOptions;
    }
239186
public void printScreen(PrintWriter out, ResourceBundle reg)
        throws DBException
    {
        String strParamRecord = this.getProperty(DBParams.RECORD);      // Display record
        String strParamScreen = this.getProperty(DBParams.SCREEN);      // Display screen
//?        String strParamLimit = this.getProperty("limit");   // Display record
        if (strParamRecord == null)
            strParamRecord = DBConstants.ROOT_PACKAGE;
        if (strParamScreen == null)
            strParamScreen = Constants.BLANK;
        String strHTML = reg.getString("Default");
        if ((strHTML == null) || (strHTML.length() == 0))
            strHTML = "<hr>" +
            "<form action=\"/" + HtmlConstants.SERVLET_PATH + "\" method=\"get\">" +
            "<pre>" +
            " Record : <input type=\"text\" length=\"50\" name=\"record\" value=\"" + HtmlConstants.RECORD_TAG + "\"/>\n" +
            " Screen : <input type=\"text\" length=\"50\" name=\"screen\" value=\"" + HtmlConstants.SCREEN_TAG + "\"/>\n" +
            "  Limit : <input type=\"text\" maxlength=\"7\" name=\"limit\" value=\"200\">\n" +
            "</pre>" +
            "<input type=submit\"submit\" name=\"" + DBParams.COMMAND + "\" VALUE=\"" + ThinMenuConstants.SUBMIT + "\"/>" +
            "</form>";
        strHTML = Utility.replace(strHTML, HtmlConstants.RECORD_TAG, strParamRecord);
        strHTML = Utility.replace(strHTML, HtmlConstants.SCREEN_TAG, strParamScreen);

        if (this.getProperty(DBParams.JOB) != null)
        {
            String strCommand = this.getProperty(DBParams.JOB);
            try   {
                strCommand = URLDecoder.decode(strCommand, DBConstants.URL_ENCODING);
            } catch (Exception ex)  {
                // Ignore
            }
            strHTML = "<p>Job: " + strCommand;
            if (this.getScreenField().handleCommand(strCommand, this.getScreenField(), ScreenConstants.USE_SAME_WINDOW | DBConstants.PUSH_TO_BROWSER))
                strHTML += " queued successfully</p>";
            else
                strHTML += " queued unsuccessfully</p>";
        }
        else if (this.getProperty("menutasks") != null)
        {
            String strCommand = this.getProperty("menutasks");
            Task task = this.getTask();
            if (task == null)
                task = BaseApplet.getSharedInstance();  // ??
//x         TaskScheduler js = task.getApplication().getTaskScheduler();
            PrivateTaskScheduler js = new PrivateTaskScheduler(task.getApplication(), 0, true);
            strHTML = "<p>Multiple Job queue: " + strCommand + "</p>";
            Record recMenu = Record.makeRecordFromClassName(MenusModel.THICK_CLASS, ((DefaultHtmlScreen)this.getScreenField()));
            recMenu.setKeyArea(MenusModel.CODE_KEY);
            recMenu.getField(MenusModel.CODE).setString(strCommand);
            String strMenuObjectID = null;
            if (recMenu.seek("="))
                strMenuObjectID = recMenu.getField(MenusModel.ID).toString();
            if ((strMenuObjectID != null) && (strMenuObjectID.length() > 0))
            {
                recMenu.close();
                recMenu.setKeyArea(MenusModel.PARENT_FOLDER_ID_KEY);
                StringSubFileFilter behMenu = new StringSubFileFilter(strMenuObjectID, recMenu.getField(MenusModel.PARENT_FOLDER_ID), null, null, null, null);
                recMenu.addListener(behMenu);
                while (recMenu.hasNext())
                {
                    recMenu.next();
                    String strLink = ((MenusModel)recMenu).getLink();
                    Map<String,Object> properties = new Hashtable<String,Object>();
                    Util.parseArgs(properties, strLink);
                    strCommand = (String)properties.get(DBParams.JOB);
                    if (strCommand != null)
                    {
                        try   {
                            strCommand = URLDecoder.decode(strCommand, DBConstants.URL_ENCODING);
                        } catch (java.io.UnsupportedEncodingException ex) {
                            ex.printStackTrace();
                        }
                        strHTML += "<p>Job: " + strCommand;
                        js.addTask(strCommand);
                        strHTML += " queued successfully</p>";
                    }
                    else
                        strHTML += "<p>Job: " + strCommand + " illegal job name</p>";
                }
            }
            recMenu.free();
            recMenu = null;
            js.endOfJobs();     // This thing will stop now when its done.
        }
        
        out.println(strHTML);
    }
498685
public void open() throws DBException
    {
        m_bIsOpen = true;
        this.getRecord().setEditMode(Constants.EDIT_NONE);
        this.setDataSource(null);
    }
639289
@Override
	public void visit(SQLiteDatabaseSchema schema, SQLiteEntity entity) throws Exception {
		int indexCounter = 0;

		// generate the class name that represents the table
		String classTableName = getTableClassName(entity.getSimpleName());

		FindIndexesVisitor indexVisitor = new FindIndexesVisitor();
		List<? extends AnnotationMirror> annotationMirrors = entity.getElement().getAnnotationMirrors();
		for (AnnotationMirror annotationMirror : annotationMirrors) {
			Map<? extends ExecutableElement, ? extends AnnotationValue> elementValues = annotationMirror
					.getElementValues();

			if (BindSqlType.class.getName().equals(annotationMirror.getAnnotationType().toString())) {
				for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : elementValues
						.entrySet()) {
					// The 'entry.getKey()' here is the annotation attribute
					// name.
					String key = entry.getKey().getSimpleName().toString();
					entry.getValue().accept(indexVisitor, key);
				}
			}
		}

		PackageElement pkg = elementUtils.getPackageOf(entity.getElement());
		String packageName = pkg.isUnnamed() ? null : pkg.getQualifiedName().toString();

		AnnotationProcessorUtilis.infoOnGeneratedClasses(BindDataSource.class, packageName, classTableName);
		classBuilder = TypeSpec.classBuilder(classTableName).addModifiers(Modifier.PUBLIC)
				.addSuperinterface(SQLiteTable.class);

		BindTypeContext context = new BindTypeContext(classBuilder, TypeUtility.typeName(packageName, classTableName),
				Modifier.STATIC, Modifier.PRIVATE);

		// javadoc for class
		classBuilder.addJavadoc("<p>");
		classBuilder.addJavadoc("\nEntity <code>$L</code> is associated to table <code>$L</code>\n",
				entity.getSimpleName(), entity.getTableName());
		classBuilder.addJavadoc("This class represents table associated to entity.\n");
		classBuilder.addJavadoc("</p>\n");
		JavadocUtility.generateJavadocGeneratedBy(classBuilder);
		classBuilder.addJavadoc(" @see $T\n", TypeUtility.className(entity.getName()));

		{
			// @formatter:off
			// table_name
			FieldSpec fieldSpec = FieldSpec
					.builder(String.class, "TABLE_NAME", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
					.initializer("\"$L\"", entity.getTableName())
					.addJavadoc("Costant represents typeName of table $L\n", entity.getTableName()).build();
			classBuilder.addField(fieldSpec);
			// @formatter:on
		}

		StringBuilder bufferTable = new StringBuilder();
		StringBuilder bufferForeignKey = new StringBuilder();
		// shared between create table and drop table
		StringBuilder bufferIndexesCreate = new StringBuilder();
		StringBuilder bufferDropTable = new StringBuilder();
		StringBuilder bufferIndexesDrop = new StringBuilder();

		bufferTable.append("CREATE TABLE " + entity.getTableName());
		// define column typeName set

		String separator = "";
		bufferTable.append(" (");

		// for each column, that need to be persisted on table
		for (SQLProperty item : entity.getCollection()) {
			bufferTable.append(separator);
			bufferTable.append(item.columnName);
			bufferTable.append(" " + SQLTransformer.columnTypeAsString(item));

			switch (item.columnType) {
			case PRIMARY_KEY:
			case PRIMARY_KEY_UNMANGED:
				bufferTable.append(" PRIMARY KEY");
				if (!item.isType(String.class) && item.columnType == ColumnType.PRIMARY_KEY) {
					bufferTable.append(" AUTOINCREMENT");
				}
				bufferTable.append(" NOT NULL");
				break;
			case UNIQUE:
				bufferTable.append(" UNIQUE");
				break;
			case INDEXED:
				bufferIndexesCreate.append(String.format(" CREATE INDEX idx_%s_%s ON %s(%s);", entity.getTableName(),
						item.columnName, entity.getTableName(), item.columnName));
				bufferIndexesDrop.append(
						String.format(" DROP INDEX IF EXISTS idx_%s_%s;", entity.getTableName(), item.columnName));
				break;
			case STANDARD:
				break;
			}

			boolean nullable = item.isNullable();

			// if it is not primary key and it is not nullable, then add not
			// null
			if (!nullable && !(item.columnType == ColumnType.PRIMARY_KEY
					|| item.columnType == ColumnType.PRIMARY_KEY_UNMANGED)) {
				bufferTable.append(" NOT NULL");
			}

			// foreign key
			String foreignClassName = item.foreignParentClassName;
			if (item.isForeignKey()) {
				SQLiteEntity reference = model.getEntity(foreignClassName);

				if (reference == null) {
					// check if we have a DAO associated into DataSource
					// definition
					boolean found = false;
					for (SQLiteDaoDefinition daoDefinition : schema.getCollection()) {
						if (daoDefinition.getEntityClassName().equals(foreignClassName)) {
							found = true;
						}
					}

					if (!found) {
						throw new NoDaoElementFound(schema, TypeUtility.className(foreignClassName));
					} else {
						throw new InvalidBeanTypeException(item, foreignClassName);
					}
				}

				// foreign key can ben used only with column type
				// long/Long
				if (!TypeUtility.isTypeIncludedIn(item.getPropertyType().getTypeName(), Long.class, Long.TYPE,
						String.class)) {
					throw new InvalidForeignKeyTypeException(item);
				}

				bufferForeignKey.append(", FOREIGN KEY(" + item.columnName + ") REFERENCES " + reference.getTableName()
						+ "(" + reference.getPrimaryKey().columnName + ")");

				if (item.onDeleteAction != ForeignKeyAction.NO_ACTION) {
					bufferForeignKey.append(" ON DELETE " + item.onDeleteAction.toString().replaceAll("_", " "));
				}

				if (item.onUpdateAction != ForeignKeyAction.NO_ACTION) {
					bufferForeignKey.append(" ON UPDATE " + item.onUpdateAction.toString().replaceAll("_", " "));
				}

				// INSERT as dependency only if reference is another entity.
				// Same entity can not be own dependency.
				if (!entity.equals(reference)) {
					entity.referedEntities.add(reference);
				}

			}

			separator = ", ";
		}

		// add foreign key
		bufferTable.append(bufferForeignKey.toString());		
		
				
		// add multicolumn indexes (UNIQUE)
		{
			Triple<String, String, String> multiIndexes = buldIndexes(entity, indexVisitor.getUniqueIndexes(), true,
					indexCounter);
			
			// add constraint unique (if present)
			bufferTable.append(multiIndexes.value2);
			// close the table definition
			bufferTable.append(");");
			
			if (!StringUtils.isEmpty(multiIndexes.value0)) {
				bufferTable.append(multiIndexes.value0 + ";");
				bufferIndexesDrop.append(multiIndexes.value1 + ";");
			}						
		}
		
		// add indexes creation one table
				if (bufferIndexesCreate.length() > 0) {
					bufferTable.append(bufferIndexesCreate.toString());
				}

		// add multicolumn indexes (NOT UNIQUE)
		{
			Pair<String, String> multiIndexes = buldIndexes(entity, indexVisitor.getNotUniqueIndexes(), false,
					indexCounter);
			if (!StringUtils.isEmpty(multiIndexes.value0)) {
				bufferTable.append(multiIndexes.value0 + ";");
				bufferIndexesDrop.append(multiIndexes.value1 + ";");
			}
		}
				
		

		{
			// create table SQL
			// @formatter:off
			FieldSpec.Builder fieldSpec = FieldSpec.builder(String.class, "CREATE_TABLE_SQL")
					.addModifiers(Modifier.STATIC, Modifier.FINAL, Modifier.PUBLIC);
			// @formatter:on

			// @formatter:off
			fieldSpec.addJavadoc("<p>\nDDL to create table $L\n</p>\n", entity.getTableName());
			fieldSpec.addJavadoc("\n<pre>$L</pre>\n", bufferTable.toString());
			// @formatter:on

			classBuilder.addField(fieldSpec.initializer("$S", bufferTable.toString()).build());
		}

		// drop table SQL
		// index does not need to be dropped, they are automatically detroyed
		// with tables
		if (bufferIndexesDrop.length() > 0) {
			bufferDropTable.append(bufferIndexesDrop.toString());
		}

		bufferDropTable.append("DROP TABLE IF EXISTS " + entity.getTableName() + ";");

		{
			// @formatter:off
			FieldSpec fieldSpec = FieldSpec.builder(String.class, "DROP_TABLE_SQL")
					.addModifiers(Modifier.STATIC, Modifier.FINAL, Modifier.PUBLIC)
					.initializer("$S", bufferDropTable.toString())
					.addJavadoc("<p>\nDDL to drop table $L\n</p>\n", entity.getTableName())
					.addJavadoc("\n<pre>$L</pre>\n", bufferDropTable.toString()).build();
			// @formatter:on
			classBuilder.addField(fieldSpec);
		}

		// define column typeName set
		for (ModelProperty item : entity.getCollection()) {
			item.accept(this);
		}

		ManagedPropertyPersistenceHelper.generateFieldPersistance(context, entity.getCollection(), PersistType.BYTE,
				true, Modifier.STATIC, Modifier.PUBLIC);

		model.sqlForCreate.add(bufferTable.toString());
		model.sqlForDrop.add(bufferDropTable.toString());

		generateColumnsArray(entity);

		TypeSpec typeSpec = classBuilder.build();
		JavaWriterHelper.writeJava2File(filer, packageName, typeSpec);

	}
62163
public void displayMenu() {
        while (true) {
            ConsoleMenu.println("");
            ConsoleMenu.println("Menu Options");

            final int size = menu.size();

            displayMenu(size);

            int opt;

            do {
                opt = ConsoleMenu.getInt("Enter your choice:", -1);
            } while ((opt <= 0 || opt > methods.size()) && opt != EXIT_CODE);

            if (opt == EXIT_CODE) {
                callTearDownIfRequired();
                return;
            }

            callMenuOption(opt);
        }
    }
305935
private void createTables() throws SQLException {
        Statement stmt = this.conn.createStatement();

        stmt.execute(DbConstants.DROP_METADATA_STATEMENT);
        stmt.execute(DbConstants.DROP_INDEX_STATEMENT);
        stmt.execute(DbConstants.DROP_CATEGORY_MAP_STATEMENT);
        stmt.execute(DbConstants.DROP_DATA_STATEMENT);
        stmt.execute(DbConstants.DROP_CATEGORIES_STATEMENT);

        stmt.execute(DbConstants.CREATE_CATEGORIES_STATEMENT);
        stmt.execute(DbConstants.CREATE_DATA_STATEMENT);
        stmt.execute(DbConstants.CREATE_CATEGORY_MAP_STATEMENT);
        stmt.execute(DbConstants.CREATE_INDEX_STATEMENT);
        stmt.execute(DbConstants.CREATE_METADATA_STATEMENT);

        stmt.close();
    }
989945
public void printScreen(PrintWriter out, ResourceBundle reg)
        throws DBException
    {
        String strHTML = "";

        ClassInfoModel classInfo = (ClassInfoModel)Record.makeRecordFromClassName(ClassInfoModel.THICK_CLASS, ((HelpScreen)this.getScreenField()));
        if (classInfo != null)
            classInfo = classInfo.readClassInfo(((HelpScreen)this.getScreenField()), null);

        String strClassName = classInfo.getClassName();
        if ((strClassName != null) && (strClassName.equalsIgnoreCase("MenuScreen")))
        {
            strHTML = reg.getString("htmlHelpMenu");
            if ((strHTML == null) || (strHTML.length() == 0))
                strHTML =
                    "<CENTER><h2>" + HtmlConstants.TITLE_TAG + "</h2></CENTER>" +
                    "<h3>Description:</h3>" +
                    "<p>" + HtmlConstants.MENU_DESC_TAG + "</p>" + 
                    "<h3>Menu items:</h3>";
            Record menu = Record.makeRecordFromClassName(MenusModel.THICK_CLASS, null);
            menu.setKeyArea(MenusModel.TYPE_KEY);
            menu.getField(MenusModel.TYPE).setString(DBParams.MENU);
            String strParamMenu = this.getProperty(DBParams.MENU);      // Display record
            menu.getField(MenusModel.PROGRAM).setString(strParamMenu);
            boolean bSuccess = menu.seek("=");
            if (!bSuccess)
                ;   // Do something?
            XMLParser parser = new MenuParser((HelpScreen)this.getScreenField(), menu);
            parser.parseHtmlData(out, strHTML);
            parser.free();
            parser = null;

            menu.free();
            menu = null;
        }
        else
        {
            if (strHTML.length() == 0)
            {
                if ((strClassName != null) && (strClassName.length() > 0))
                    strHTML = reg.getString("htmlHelp");
                else
                {
                    strHTML = reg.getString("htmlHelpDefault");
                    out.println(strHTML);
                    classInfo.free();
                    classInfo = null;
                    return;
                }
            }
            if ((strHTML == null) || (strHTML.length() == 0))
                strHTML =
                "<h2>" + HtmlConstants.TITLE_TAG + "</h2>" +
                "<h3>Description:</h3>" +
                "<p>" + HtmlConstants.MENU_DESC_TAG + "</p>" +
                "<h3>Operation:</h3>" +
                "<p>" + HtmlConstants.HELP_TAG + "</p>";
    
            XMLParser parser = new HelpParser((HelpScreen)this.getScreenField(), classInfo);
            parser.parseHtmlData(out, strHTML);
            parser.free();
            parser = null;
        }
        classInfo.free();
        classInfo = null;
    }