/** * Returns the contact that uses the specified email address. The search performed is * case-sensitive. * * @param email the email address of the desired contact * @return the contact that is associated with the given email address, or <code>null</code> if * none could be found */ public Contact getContact(String email) { for (int i = 0; i < contacts.size(); i++) { Contact contact = (Contact) contacts.get(i); if (contact.getEmail().equals(email)) { return contact; } } return null; }
/** * Load infos from contact in the corresponding views. * * @param c contact */ public void set(Contact c) { contact = c; setPerson(c); if (c != null) { setAddress(c.getAddress()); setTele(c.getTele()); setEmail(c.getEmail()); websiteView.setSites(c.getSites()); } }
public void addContact(Contact contact) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(CONTACTS_COLUMN_CONTACT_ID, contact.getId()); values.put(CONTACTS_COLUMN_NAME, contact.getName()); // Contact Name values.put(CONTACTS_COLUMN_PHONE, contact.getPhone()); // Contact Phone // Number values.put(CONTACTS_COLUMN_EMAIL, contact.getEmail()); values.put(CONTACTS_COLUMN_CATEGORY, contact.getCategory()); // Inserting Row db.insert(CONTACTS_TABLE_NAME, null, values); db.close(); // Closing database connection }
private void StartContactUpdateFragment() { if (contactLoaded != null) { ContactUpdateFragment contactUpdateFragment = ContactUpdateFragment.newInstance( new Contact( contactLoaded.getId(), contactLoaded.getFirstName(), contactLoaded.getLastName(), contactLoaded.getEmail())); getSupportFragmentManager() .beginTransaction() .replace(android.R.id.content, contactUpdateFragment) .commit(); } }
public int updateContact(Contact contact) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(CONTACTS_COLUMN_NAME, contact.getName()); values.put(CONTACTS_COLUMN_PHONE, contact.getPhone()); values.put(CONTACTS_COLUMN_EMAIL, contact.getEmail()); values.put(CONTACTS_COLUMN_CATEGORY, contact.getCategory()); // updating row return db.update( CONTACTS_TABLE_NAME, values, CONTACTS_COLUMN_ID + " = ?", new String[] {String.valueOf(contact.getId())}); }
// Insert new contact information public void insertContact(Contact c) { db = this.getWritableDatabase(); ContentValues values = new ContentValues(); String query = "select * from contacts"; Cursor cursor = db.rawQuery(query, null); int count = cursor.getCount(); values.put(COLUMN_ID, count); values.put(COLUMN_NAME, c.getName()); values.put(COLUMN_EMAIL, c.getEmail()); values.put(COLUMN_STAGE, "0"); values.put(COLUMN_PASS, c.getPass()); db.insert(TABLE_NAME, null, values); db.close(); }
public void action() { Contact contact = new Contact(); String name, phone; name = JOptionPane.showInputDialog("Ange namn"); contact.setName(name); phone = JOptionPane.showInputDialog("Ange hemtelefon"); contact.setPhone(phone); contact.setMobile(JOptionPane.showInputDialog("Ange mobil")); contact.setEmail(JOptionPane.showInputDialog("Ange mail-adress")); JOptionPane.showMessageDialog(null, contact.toString()); JOptionPane.showMessageDialog( null, contact.getName() + "\n" + contact.getPhone() + "\n" + contact.getMobile() + "\n" + contact.getEmail()); }
private void getUpdatedContactInfo(Contact currentContact) { EditText editText = (EditText) this.findViewById(R.id.contactName); currentContact.setName(editText.getText().toString()); EditText aliasText = (EditText) this.findViewById(R.id.alias); currentContact.setAlias(aliasText.getText().toString()); EditText businessText = (EditText) this.findViewById(R.id.business_edit); currentContact.setBusiness(businessText.getText().toString()); final EditText phoneText = (EditText) this.findViewById(R.id.phone_edit); final Spinner phoneOptions = (Spinner) this.findViewById(R.id.phone_spinner); currentContact.setPhone(new HashMap<String, String>()); currentContact .getPhone() .put(phoneOptions.getSelectedItem().toString(), phoneText.getText().toString()); final EditText emailText = (EditText) this.findViewById(R.id.email_edit); final Spinner emailOptions = (Spinner) this.findViewById(R.id.email_spinner); currentContact.setEmail(new HashMap<String, String>()); currentContact .getEmail() .put(emailOptions.getSelectedItem().toString(), emailText.getText().toString()); final EditText streetText = (EditText) this.findViewById(R.id.address1_edit); final EditText cityText = (EditText) this.findViewById(R.id.address_city_edit); final EditText zipText = (EditText) this.findViewById(R.id.zip_code_edit); final Spinner stateOptions = (Spinner) this.findViewById(R.id.state_spinner); final Spinner addressOptions = (Spinner) this.findViewById(R.id.address_spinner); currentContact.setAddresses(new HashMap<String, Address>()); currentContact .getAddresses() .put( addressOptions.getSelectedItem().toString(), new Address( streetText.getText().toString(), cityText.getText().toString(), stateOptions.getSelectedItem().toString(), zipText.getText().toString())); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_contact); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); final EditText name = (EditText) findViewById(R.id.edit_name); final EditText phone = (EditText) findViewById(R.id.edit_phone); final EditText email = (EditText) findViewById(R.id.edit_email); final EditText address = (EditText) findViewById(R.id.edit_address); final EditText digicode = (EditText) findViewById(R.id.edit_digicode); Bundle extra = getIntent().getExtras(); if (extra != null) { final int id = extra.getInt("id"); Contact contact = db.getContact(id); name.setText(contact.getName()); phone.setText(contact.getPhone()); email.setText(contact.getEmail()); address.setText(contact.getAddress()); digicode.setText(contact.getDigicode()); FloatingActionButton update = (FloatingActionButton) findViewById(R.id.update_btn); update.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { db.updateContact( id, name.getText().toString(), phone.getText().toString(), email.getText().toString(), address.getText().toString(), digicode.getText().toString()); Intent i = new Intent(EditContact.this, MainActivity.class); startActivity(i); } }); } }
public void updateCategory(Contact contact) { SQLiteDatabase db = this.getWritableDatabase(); String selectQuery = "UPDATE " + CONTACTS_TABLE_NAME + " SET category='" + contact.getCategory() + "'" + " WHERE name='" + contact.getName() + "' AND " + "phone='" + contact.getPhone() + "' AND " + "email='" + contact.getEmail() + "';"; // String selectQuery = "UPDATE " + CONTACTS_TABLE_NAME // + " SET category='" + contact.getCategory() + "';"; db.execSQL(selectQuery); }
// ***************************************************************************** // Save Contact using HTTP PUT method with singleContactUrl. // If Id is zero(0) a new Contact will be added. // If Id is non-zero an existing Contact will be updated. // HTTP POST could be used to add a new Contact but the ContactService knows // an Id of zero means a new Contact so in this case the HTTP PUT is used. // ***************************************************************************** public Integer SaveContact(Contact saveContact) { Integer statusCode = 0; HttpResponse response; try { boolean isValid = true; // Data validation goes here if (isValid) { // POST request to <service>/SaveVehicle HttpPut request = new HttpPut(singleContactUrl + saveContact.getId()); request.setHeader("User-Agent", "dev.ronlemire.contactClient"); request.setHeader("Accept", "application/json"); request.setHeader("Content-type", "application/json"); // Build JSON string JSONStringer contact = new JSONStringer() .object() .key("Id") .value(Integer.parseInt(saveContact.getId())) .key("FirstName") .value(saveContact.getFirstName()) .key("LastName") .value(saveContact.getLastName()) .key("Email") .value(saveContact.getEmail()) .endObject(); StringEntity entity = new StringEntity(contact.toString()); request.setEntity(entity); // Send request to WCF service DefaultHttpClient httpClient = new DefaultHttpClient(); response = httpClient.execute(request); Log.d("WebInvoke", "Saving : " + response.getStatusLine().getStatusCode()); // statusCode = // Integer.toString(response.getStatusLine().getStatusCode()); statusCode = response.getStatusLine().getStatusCode(); if (saveContact.getId().equals("0")) { // New Contact.Id is in buffer HttpEntity responseEntity = response.getEntity(); char[] buffer = new char[(int) responseEntity.getContentLength()]; InputStream stream = responseEntity.getContent(); InputStreamReader reader = new InputStreamReader(stream); reader.read(buffer); stream.close(); statusCode = Integer.parseInt(new String(buffer)); } else { statusCode = response.getStatusLine().getStatusCode(); } } } catch (Exception e) { e.printStackTrace(); } return statusCode; }
public void setOppositeSelection(Contact contact) { setOppositeSelection(contact.getEmail()); }
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.add_update_screen); // set screen Set_Add_Update_Screen(); // set visibility of view as per calling activity String called_from = getIntent().getStringExtra("called"); if (called_from.equalsIgnoreCase("add")) { add_view.setVisibility(View.VISIBLE); update_view.setVisibility(View.GONE); } else { update_view.setVisibility(View.VISIBLE); add_view.setVisibility(View.GONE); USER_ID = Integer.parseInt(getIntent().getStringExtra("USER_ID")); Contact c = dbHandler.Get_Contact(USER_ID); add_name.setText(c.getName()); add_mobile.setText(c.getPhoneNumber()); add_email.setText(c.getEmail()); // dbHandler.close(); } add_mobile.addTextChangedListener( new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub // min lenth 10 and max lenth 12 (2 extra for - as per phone // matcher format) Is_Valid_Sign_Number_Validation(12, 12, add_mobile); } }); add_mobile.addTextChangedListener(new PhoneNumberFormattingTextWatcher()); add_email.addTextChangedListener( new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub Is_Valid_Email(add_email); } }); add_name.addTextChangedListener( new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub Is_Valid_Person_Name(add_name); } }); add_save_btn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // check the value state is null or not if (valid_name != null && valid_mob_number != null && valid_email != null && valid_name.length() != 0 && valid_mob_number.length() != 0 && valid_email.length() != 0) { dbHandler.Add_Contact(new Contact(valid_name, valid_mob_number, valid_email)); Toast_msg = "Data inserted successfully"; Show_Toast(Toast_msg); Reset_Text(); } } }); update_btn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub valid_name = add_name.getText().toString(); valid_mob_number = add_mobile.getText().toString(); valid_email = add_email.getText().toString(); // check the value state is null or not if (valid_name != null && valid_mob_number != null && valid_email != null && valid_name.length() != 0 && valid_mob_number.length() != 0 && valid_email.length() != 0) { dbHandler.Update_Contact( new Contact(USER_ID, valid_name, valid_mob_number, valid_email)); dbHandler.close(); Toast_msg = "Data Update successfully"; Show_Toast(Toast_msg); Reset_Text(); } else { Toast_msg = "Sorry Some Fields are missing.\nPlease Fill up all."; Show_Toast(Toast_msg); } } }); update_view_all.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent view_user = new Intent(Add_Update_User.this, Main_Screen.class); view_user.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(view_user); finish(); } }); add_view_all.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent view_user = new Intent(Add_Update_User.this, Main_Screen.class); view_user.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(view_user); finish(); } }); }
@Override public List<File> generate() { Boolean generateApis = null; Boolean generateModels = null; Boolean generateSupportingFiles = null; Set<String> modelsToGenerate = null; Set<String> apisToGenerate = null; Set<String> supportingFilesToGenerate = null; // allows generating only models by specifying a CSV of models to generate, or empty for all if (System.getProperty("models") != null) { String modelNames = System.getProperty("models"); generateModels = true; if (!modelNames.isEmpty()) { modelsToGenerate = new HashSet<String>(Arrays.asList(modelNames.split(","))); } } if (System.getProperty("apis") != null) { String apiNames = System.getProperty("apis"); generateApis = true; if (!apiNames.isEmpty()) { apisToGenerate = new HashSet<String>(Arrays.asList(apiNames.split(","))); } } if (System.getProperty("supportingFiles") != null) { String supportingFiles = System.getProperty("supportingFiles"); generateSupportingFiles = true; if (!supportingFiles.isEmpty()) { supportingFilesToGenerate = new HashSet<String>(Arrays.asList(supportingFiles.split(","))); } } if (generateApis == null && generateModels == null && generateSupportingFiles == null) { // no specifics are set, generate everything generateApis = true; generateModels = true; generateSupportingFiles = true; } else { if (generateApis == null) { generateApis = false; } if (generateModels == null) { generateModels = false; } if (generateSupportingFiles == null) { generateSupportingFiles = false; } } if (swagger == null || config == null) { throw new RuntimeException("missing swagger input or config!"); } if (System.getProperty("debugSwagger") != null) { Json.prettyPrint(swagger); } List<File> files = new ArrayList<File>(); config.processOpts(); config.preprocessSwagger(swagger); config.additionalProperties().put("generatedDate", DateTime.now().toString()); config.additionalProperties().put("generatorClass", config.getClass().toString()); if (swagger.getInfo() != null) { Info info = swagger.getInfo(); if (info.getTitle() != null) { config.additionalProperties().put("appName", info.getTitle()); } if (info.getVersion() != null) { config.additionalProperties().put("appVersion", info.getVersion()); } if (info.getDescription() != null) { config .additionalProperties() .put("appDescription", config.escapeText(info.getDescription())); } if (info.getContact() != null) { Contact contact = info.getContact(); config.additionalProperties().put("infoUrl", contact.getUrl()); if (contact.getEmail() != null) { config.additionalProperties().put("infoEmail", contact.getEmail()); } } if (info.getLicense() != null) { License license = info.getLicense(); if (license.getName() != null) { config.additionalProperties().put("licenseInfo", license.getName()); } if (license.getUrl() != null) { config.additionalProperties().put("licenseUrl", license.getUrl()); } } if (info.getVersion() != null) { config.additionalProperties().put("version", info.getVersion()); } } StringBuilder hostBuilder = new StringBuilder(); String scheme; if (swagger.getSchemes() != null && swagger.getSchemes().size() > 0) { scheme = swagger.getSchemes().get(0).toValue(); } else { scheme = "https"; } hostBuilder.append(scheme); hostBuilder.append("://"); if (swagger.getHost() != null) { hostBuilder.append(swagger.getHost()); } else { hostBuilder.append("localhost"); } if (swagger.getBasePath() != null) { hostBuilder.append(swagger.getBasePath()); } String contextPath = swagger.getBasePath() == null ? "" : swagger.getBasePath(); String basePath = hostBuilder.toString(); String basePathWithoutHost = swagger.getBasePath(); // resolve inline models InlineModelResolver inlineModelResolver = new InlineModelResolver(); inlineModelResolver.flatten(swagger); List<Object> allOperations = new ArrayList<Object>(); List<Object> allModels = new ArrayList<Object>(); // models Map<String, Model> definitions = swagger.getDefinitions(); if (definitions != null) { List<String> sortedModelKeys = sortModelsByInheritance(definitions); if (generateModels) { if (modelsToGenerate != null && modelsToGenerate.size() > 0) { List<String> updatedKeys = new ArrayList<String>(); for (String m : sortedModelKeys) { if (modelsToGenerate.contains(m)) { updatedKeys.add(m); } } sortedModelKeys = updatedKeys; } for (String name : sortedModelKeys) { try { // don't generate models that have an import mapping if (config.importMapping().containsKey(name)) { continue; } Model model = definitions.get(name); Map<String, Model> modelMap = new HashMap<String, Model>(); modelMap.put(name, model); Map<String, Object> models = processModels(config, modelMap, definitions); models.putAll(config.additionalProperties()); allModels.add(((List<Object>) models.get("models")).get(0)); for (String templateName : config.modelTemplateFiles().keySet()) { String suffix = config.modelTemplateFiles().get(templateName); String filename = config.modelFileFolder() + File.separator + config.toModelFilename(name) + suffix; if (!config.shouldOverwrite(filename)) { continue; } String templateFile = getFullTemplateFile(config, templateName); String template = readTemplate(templateFile); Template tmpl = Mustache.compiler() .withLoader( new Mustache.TemplateLoader() { @Override public Reader getTemplate(String name) { return getTemplateReader( getFullTemplateFile(config, name + ".mustache")); } }) .defaultValue("") .compile(template); writeToFile(filename, tmpl.execute(models)); files.add(new File(filename)); } // to generate model test files for (String templateName : config.modelTestTemplateFiles().keySet()) { String suffix = config.modelTestTemplateFiles().get(templateName); String filename = config.modelTestFileFolder() + File.separator + config.toModelTestFilename(name) + suffix; if (!config.shouldOverwrite(filename)) { continue; } String templateFile = getFullTemplateFile(config, templateName); String template = readTemplate(templateFile); Template tmpl = Mustache.compiler() .withLoader( new Mustache.TemplateLoader() { @Override public Reader getTemplate(String name) { return getTemplateReader( getFullTemplateFile(config, name + ".mustache")); } }) .defaultValue("") .compile(template); writeToFile(filename, tmpl.execute(models)); files.add(new File(filename)); } } catch (Exception e) { throw new RuntimeException("Could not generate model '" + name + "'", e); } } } } if (System.getProperty("debugModels") != null) { LOGGER.info("############ Model info ############"); Json.prettyPrint(allModels); } // apis Map<String, List<CodegenOperation>> paths = processPaths(swagger.getPaths()); if (generateApis) { if (apisToGenerate != null && apisToGenerate.size() > 0) { Map<String, List<CodegenOperation>> updatedPaths = new TreeMap<String, List<CodegenOperation>>(); for (String m : paths.keySet()) { if (apisToGenerate.contains(m)) { updatedPaths.put(m, paths.get(m)); } } paths = updatedPaths; } for (String tag : paths.keySet()) { try { List<CodegenOperation> ops = paths.get(tag); Map<String, Object> operation = processOperations(config, tag, ops); operation.put("basePath", basePath); operation.put("basePathWithoutHost", basePathWithoutHost); operation.put("contextPath", contextPath); operation.put("baseName", tag); operation.put("modelPackage", config.modelPackage()); operation.putAll(config.additionalProperties()); operation.put("classname", config.toApiName(tag)); operation.put("classVarName", config.toApiVarName(tag)); operation.put("importPath", config.toApiImport(tag)); // Pass sortParamsByRequiredFlag through to the Mustache template... boolean sortParamsByRequiredFlag = true; if (this.config .additionalProperties() .containsKey(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG)) { sortParamsByRequiredFlag = Boolean.valueOf( (String) this.config .additionalProperties() .get(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG) .toString()); } operation.put("sortParamsByRequiredFlag", sortParamsByRequiredFlag); processMimeTypes(swagger.getConsumes(), operation, "consumes"); processMimeTypes(swagger.getProduces(), operation, "produces"); allOperations.add(new HashMap<String, Object>(operation)); for (int i = 0; i < allOperations.size(); i++) { Map<String, Object> oo = (Map<String, Object>) allOperations.get(i); if (i < (allOperations.size() - 1)) { oo.put("hasMore", "true"); } } for (String templateName : config.apiTemplateFiles().keySet()) { String filename = config.apiFilename(templateName, tag); if (!config.shouldOverwrite(filename) && new File(filename).exists()) { continue; } String templateFile = getFullTemplateFile(config, templateName); String template = readTemplate(templateFile); Template tmpl = Mustache.compiler() .withLoader( new Mustache.TemplateLoader() { @Override public Reader getTemplate(String name) { return getTemplateReader( getFullTemplateFile(config, name + ".mustache")); } }) .defaultValue("") .compile(template); writeToFile(filename, tmpl.execute(operation)); files.add(new File(filename)); } // to generate api test files for (String templateName : config.apiTestTemplateFiles().keySet()) { String filename = config.apiTestFilename(templateName, tag); if (!config.shouldOverwrite(filename) && new File(filename).exists()) { continue; } String templateFile = getFullTemplateFile(config, templateName); String template = readTemplate(templateFile); Template tmpl = Mustache.compiler() .withLoader( new Mustache.TemplateLoader() { @Override public Reader getTemplate(String name) { return getTemplateReader( getFullTemplateFile(config, name + ".mustache")); } }) .defaultValue("") .compile(template); writeToFile(filename, tmpl.execute(operation)); files.add(new File(filename)); } } catch (Exception e) { throw new RuntimeException("Could not generate api file for '" + tag + "'", e); } } } if (System.getProperty("debugOperations") != null) { LOGGER.info("############ Operation info ############"); Json.prettyPrint(allOperations); } // supporting files Map<String, Object> bundle = new HashMap<String, Object>(); bundle.putAll(config.additionalProperties()); bundle.put("apiPackage", config.apiPackage()); Map<String, Object> apis = new HashMap<String, Object>(); apis.put("apis", allOperations); if (swagger.getHost() != null) { bundle.put("host", swagger.getHost()); } bundle.put("swagger", this.swagger); bundle.put("basePath", basePath); bundle.put("scheme", scheme); bundle.put("contextPath", contextPath); bundle.put("apiInfo", apis); bundle.put("models", allModels); bundle.put("apiFolder", config.apiPackage().replace('.', File.separatorChar)); bundle.put("modelPackage", config.modelPackage()); List<CodegenSecurity> authMethods = config.fromSecurity(swagger.getSecurityDefinitions()); if (authMethods != null && !authMethods.isEmpty()) { bundle.put("authMethods", authMethods); bundle.put("hasAuthMethods", true); } if (swagger.getExternalDocs() != null) { bundle.put("externalDocs", swagger.getExternalDocs()); } for (int i = 0; i < allModels.size() - 1; i++) { HashMap<String, CodegenModel> cm = (HashMap<String, CodegenModel>) allModels.get(i); CodegenModel m = cm.get("model"); m.hasMoreModels = true; } config.postProcessSupportingFileData(bundle); if (System.getProperty("debugSupportingFiles") != null) { LOGGER.info("############ Supporting file info ############"); Json.prettyPrint(bundle); } if (generateSupportingFiles) { for (SupportingFile support : config.supportingFiles()) { try { String outputFolder = config.outputFolder(); if (isNotEmpty(support.folder)) { outputFolder += File.separator + support.folder; } File of = new File(outputFolder); if (!of.isDirectory()) { of.mkdirs(); } String outputFilename = outputFolder + File.separator + support.destinationFilename; if (!config.shouldOverwrite(outputFilename)) { continue; } String templateFile = getFullTemplateFile(config, support.templateFile); boolean shouldGenerate = true; if (supportingFilesToGenerate != null && supportingFilesToGenerate.size() > 0) { if (supportingFilesToGenerate.contains(support.destinationFilename)) { shouldGenerate = true; } else { shouldGenerate = false; } } if (shouldGenerate) { if (templateFile.endsWith("mustache")) { String template = readTemplate(templateFile); Template tmpl = Mustache.compiler() .withLoader( new Mustache.TemplateLoader() { @Override public Reader getTemplate(String name) { return getTemplateReader( getFullTemplateFile(config, name + ".mustache")); } }) .defaultValue("") .compile(template); writeToFile(outputFilename, tmpl.execute(bundle)); files.add(new File(outputFilename)); } else { InputStream in = null; try { in = new FileInputStream(templateFile); } catch (Exception e) { // continue } if (in == null) { in = this.getClass() .getClassLoader() .getResourceAsStream(getCPResourcePath(templateFile)); } File outputFile = new File(outputFilename); OutputStream out = new FileOutputStream(outputFile, false); if (in != null) { LOGGER.info("writing file " + outputFile); IOUtils.copy(in, out); } else { if (in == null) { LOGGER.error("can't open " + templateFile + " for input"); } } files.add(outputFile); } } } catch (Exception e) { throw new RuntimeException("Could not generate supporting file '" + support + "'", e); } } } config.processSwagger(swagger); return files; }
/** Builds the document header of the swagger model */ private void overview() { Info info = swagger.getInfo(); this.markupDocBuilder.documentTitle(info.getTitle()); this.markupDocBuilder.sectionTitleLevel1(OVERVIEW); if (isNotBlank(info.getDescription())) { this.markupDocBuilder.textLine(info.getDescription()); } if (isNotBlank(info.getVersion())) { this.markupDocBuilder.sectionTitleLevel2(CURRENT_VERSION); this.markupDocBuilder.textLine(VERSION + info.getVersion()); } Contact contact = info.getContact(); if (contact != null) { this.markupDocBuilder.sectionTitleLevel2(CONTACT_INFORMATION); if (isNotBlank(contact.getName())) { this.markupDocBuilder.textLine(CONTACT_NAME + contact.getName()); } if (isNotBlank(contact.getEmail())) { this.markupDocBuilder.textLine(CONTACT_EMAIL + contact.getEmail()); } } License license = info.getLicense(); if (license != null && (isNotBlank(license.getName()) || isNotBlank(license.getUrl()))) { this.markupDocBuilder.sectionTitleLevel2(LICENSE_INFORMATION); if (isNotBlank(license.getName())) { this.markupDocBuilder.textLine(LICENSE + license.getName()); } if (isNotBlank(license.getUrl())) { this.markupDocBuilder.textLine(LICENSE_URL + license.getUrl()); } } if (isNotBlank(info.getTermsOfService())) { this.markupDocBuilder.textLine(TERMS_OF_SERVICE + info.getTermsOfService()); } if (isNotBlank(swagger.getHost()) || isNotBlank(swagger.getBasePath()) || isNotEmpty(swagger.getSchemes())) { this.markupDocBuilder.sectionTitleLevel2(URI_SCHEME); if (isNotBlank(swagger.getHost())) { this.markupDocBuilder.textLine(HOST + swagger.getHost()); } if (isNotBlank(swagger.getBasePath())) { this.markupDocBuilder.textLine(BASE_PATH + swagger.getBasePath()); } if (isNotEmpty(swagger.getSchemes())) { List<String> schemes = new ArrayList<>(); for (Scheme scheme : swagger.getSchemes()) { schemes.add(scheme.toString()); } this.markupDocBuilder.textLine(SCHEMES + join(schemes, ", ")); } } if (isNotEmpty(swagger.getTags())) { this.markupDocBuilder.sectionTitleLevel2(TAGS); List<String> tags = new ArrayList<>(); for (Tag tag : swagger.getTags()) { String name = tag.getName(); String description = tag.getDescription(); if (isNoneBlank(description)) { tags.add(name + ": " + description); } else { tags.add(name); } } this.markupDocBuilder.unorderedList(tags); } if (isNotEmpty(swagger.getConsumes())) { this.markupDocBuilder.sectionTitleLevel2(CONSUMES); this.markupDocBuilder.unorderedList(swagger.getConsumes()); } if (isNotEmpty(swagger.getProduces())) { this.markupDocBuilder.sectionTitleLevel2(PRODUCES); this.markupDocBuilder.unorderedList(swagger.getProduces()); } }
@JsonIgnore @Transient public String getEmail() { return kontak.getEmail(); }
public static void main(String[] args) { Contact testContact = new Contact(); String input = null; // variable for users input Scanner keyboard = new Scanner(System.in); // creates Scanner Object System.out.print("Enter the last name: "); input = keyboard.nextLine(); // changes value of input testContact.setLastName(input); // sends input to setLastName method to be validated System.out.println("Last name: " + testContact.getLastName()); // displays users input System.out.print("Enter the first name: "); input = keyboard.nextLine(); // changes value of input testContact.setFirstName(input); // sends input to setFirstName method to be validated System.out.println("First name: " + testContact.getFirstName()); // displays users input System.out.print("Enter the Middle name: "); input = keyboard.nextLine(); // changes value of input testContact.setMiddleName(input); // sends input to setMiddleName method to be validated System.out.println("Middle name: " + testContact.getMiddleName()); // displays users input System.out.print("Enter the prefix (if you have none, input none): "); input = keyboard.nextLine(); // changes value of input testContact.setPrefix(input); // sends input to setPrefix method to be validated System.out.println("Prefix: " + testContact.getPrefix()); // displays users input System.out.print("Enter the phone number: "); input = keyboard.nextLine(); // changes value of input testContact.setPhoneNum(input); // sends input to setPhoneNum method to be validated System.out.println("Phone number: " + testContact.getPhoneNum()); // displays users input System.out.print("Enter the Email: "); input = keyboard.nextLine(); // changes value of input testContact.setEmail(input); // sends input to setEmail method to be validated System.out.println("Email: " + testContact.getEmail()); // displays users input System.out.print("Enter the Street: "); input = keyboard.nextLine(); // changes value of input testContact.setStreet(input); // sends input to setStreet method to be validated System.out.println("Street: " + testContact.getEmail()); // displays users input System.out.print("Enter the City: "); input = keyboard.nextLine(); // changes value of input testContact.setCity(input); // sends input to setCity method to be validated System.out.println("City: " + testContact.getCity()); // displays users input System.out.print("Enter the State: "); input = keyboard.nextLine(); // changes value of input testContact.setState(input); // sends input to setState method to be validated System.out.println("State: " + testContact.getState()); // displays users input System.out.print("Enter the Zip Code: "); input = keyboard.nextLine(); // changes value of input testContact.setZipCode(input); // sends input to setZipCode method to be validated System.out.println("Zip code: " + testContact.getZipCode()); // displays users input System.out.print("Enter the Occupation: "); input = keyboard.nextLine(); // changes value of input testContact.setOcupation(input); // sends input to setOccupation method to be validated System.out.println("Occupation: " + testContact.getOccupation()); // displays users input }