Search in sources :

Example 1 with Account

use of Model.Account in project googleads-adsense-examples by googleads.

the class GetAllAccounts method run.

/**
 * Runs this sample.
 *
 * @param adsense AdSense service object on which to run the requests.
 * @param maxPageSize the maximum page size to retrieve.
 * @return the retrieved accounts.
 * @throws Exception
 */
public static List<Account> run(Adsense adsense, int maxPageSize) throws Exception {
    System.out.println("=================================================================");
    System.out.println("Listing all AdSense accounts");
    System.out.println("=================================================================");
    List<Account> allAccounts = new ArrayList<Account>();
    // Retrieve account list in pages and display data as we receive it.
    String pageToken = null;
    do {
        ListAccountsResponse response = null;
        response = adsense.accounts().list().setPageSize(maxPageSize).setPageToken(pageToken).execute();
        List<Account> accounts = response.getAccounts();
        if (accounts != null && !accounts.isEmpty()) {
            allAccounts.addAll(accounts);
            for (Account account : accounts) {
                System.out.printf("Account with ID \"%s\" and name \"%s\" was found.\n", account.getName(), account.getDisplayName());
            }
        } else {
            System.out.println("No accounts found.");
        }
        pageToken = response.getNextPageToken();
    } while (pageToken != null);
    System.out.println();
    return allAccounts;
}
Also used : Account(com.google.api.services.adsense.v2.model.Account) ListAccountsResponse(com.google.api.services.adsense.v2.model.ListAccountsResponse) ArrayList(java.util.ArrayList)

Example 2 with Account

use of Model.Account in project googleads-adsense-examples by googleads.

the class AdSenseSample method main.

/**
 * Runs all the AdSense Management API samples.
 *
 * @param args command-line arguments.
 */
public static void main(String[] args) {
    try {
        httpTransport = GoogleNetHttpTransport.newTrustedTransport();
        dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);
        Adsense adsense = initializeAdsense();
        List<Account> accounts = GetAllAccounts.run(adsense, MAX_LIST_PAGE_SIZE);
        if ((accounts != null) && !accounts.isEmpty()) {
            // Get an example account ID, so we can run the following sample.
            String chosenAccount = chooseAccount(accounts);
            GetAccountTree.run(adsense, chosenAccount);
            List<AdClient> adClients = GetAllAdClients.run(adsense, chosenAccount, MAX_LIST_PAGE_SIZE);
            if ((adClients != null) && !adClients.isEmpty()) {
                // Get an ad client ID, so we can run the rest of the samples.
                String exampleAdClientId = adClients.get(6).getName();
                List<AdUnit> units = GetAllAdUnits.run(adsense, exampleAdClientId, MAX_LIST_PAGE_SIZE);
                if ((units != null) && !units.isEmpty()) {
                    // Get an example ad unit ID, so we can run the following sample.
                    String exampleAdUnitId = units.get(0).getName();
                    GetAllCustomChannelsForAdUnit.run(adsense, exampleAdUnitId, MAX_LIST_PAGE_SIZE);
                }
                List<CustomChannel> channels = GetAllCustomChannels.run(adsense, exampleAdClientId, MAX_LIST_PAGE_SIZE);
                if ((channels != null) && !channels.isEmpty()) {
                    // Get an example custom channel ID, so we can run the following sample.
                    String exampleCustomChannelId = channels.get(1).getName();
                    GetAllAdUnitsForCustomChannel.run(adsense, exampleCustomChannelId, MAX_LIST_PAGE_SIZE);
                }
                GetAllUrlChannels.run(adsense, exampleAdClientId, MAX_LIST_PAGE_SIZE);
                GenerateReport.run(adsense, chosenAccount, exampleAdClientId);
            } else {
                System.out.println("No ad clients found, unable to run remaining methods.");
            }
            List<SavedReport> savedReports = GetAllSavedReports.run(adsense, chosenAccount, MAX_LIST_PAGE_SIZE);
            if ((savedReports != null) && !savedReports.isEmpty()) {
                // Get a saved report ID, so we can generate its report.
                String exampleSavedReportId = savedReports.get(0).getName();
                GenerateSavedReport.run(adsense, exampleSavedReportId);
            } else {
                System.out.println("No saved report found.");
            }
            GetAllAlerts.run(adsense, chosenAccount);
        }
    } catch (IOException e) {
        System.err.println(e.getMessage());
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : Account(com.google.api.services.adsense.v2.model.Account) SavedReport(com.google.api.services.adsense.v2.model.SavedReport) IOException(java.io.IOException) FileDataStoreFactory(com.google.api.client.util.store.FileDataStoreFactory) AdUnit(com.google.api.services.adsense.v2.model.AdUnit) Adsense(com.google.api.services.adsense.v2.Adsense) AdClient(com.google.api.services.adsense.v2.model.AdClient) CustomChannel(com.google.api.services.adsense.v2.model.CustomChannel)

Example 3 with Account

use of Model.Account in project buildAPKsTutorials by SDRausty.

the class CreateAccountAdapter method processForm.

private void processForm() {
    if (mDelegate != null) {
        Account account = new Account();
        account.setCity(mFormData.get(CITY_KEY));
        account.setCountry(mFormData.get(COUNTRY_KEY));
        account.setEmail(mFormData.get(EMAIL_KEY));
        account.setGender(mFormData.get(GENDER_KEY));
        account.setName(mFormData.get(FULL_NAME_KEY));
        account.setPassword(mFormData.get(PASSWORD_KEY));
        account.setPostalCode(mFormData.get(ZIP_KEY));
        mDelegate.processForm(account);
    }
}
Also used : Account(com.manning.androidhacks.hack017.model.Account)

Example 4 with Account

use of Model.Account in project syndesis by syndesisio.

the class FhirTransactionTest method transactionTest.

@Test
@SuppressWarnings("JdkObsolete")
public void transactionTest() {
    Bundle bundle = new Bundle();
    bundle.addEntry(new Bundle.BundleEntryComponent().setResource(new Account().setId("1").setMeta(new Meta().setLastUpdated(new Date()))));
    bundle.addEntry(new Bundle.BundleEntryComponent().setResource(new Patient().setId("2").setMeta(new Meta().setLastUpdated(new Date()))));
    stubFhirRequest(post(urlEqualTo("/?_format=xml")).withRequestBody(containing("<type value=\"transaction\"/><total value=\"2\"/><link><relation value=\"fhir-base\"/></link>" + "<link><relation value=\"self\"/></link>" + "<entry><resource><Account xmlns=\"http://hl7.org/fhir\"><name value=\"Joe\"/></Account></resource>" + "<request><method value=\"POST\"/></request></entry><entry><resource>" + "<Patient xmlns=\"http://hl7.org/fhir\"><name><family value=\"Jackson\"/></name></Patient></resource>" + "<request><method value=\"POST\"/></request></entry>")).willReturn(okXml(toXml(bundle))));
    template.requestBody("direct:start", "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<tns:Transaction xmlns:tns=\"http://hl7.org/fhir\">" + "<tns:Account><tns:name value=\"Joe\"/></tns:Account>" + "<tns:Patient><name><tns:family value=\"Jackson\"/></name></tns:Patient></tns:Transaction>");
}
Also used : Account(org.hl7.fhir.dstu3.model.Account) Meta(org.hl7.fhir.dstu3.model.Meta) Bundle(org.hl7.fhir.dstu3.model.Bundle) Patient(org.hl7.fhir.dstu3.model.Patient) Date(java.util.Date) Test(org.junit.Test)

Example 5 with Account

use of Model.Account in project Happourse_online_study_web by infiq2000.

the class Login method doPost.

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String userName = request.getParameter("username");
    String passWord = request.getParameter("password");
    try {
        User user = null;
        Account tmp = accUtil.validation(userName, passWord);
        if (tmp != null) {
            if (!tmp.isType()) {
                user = userUtil.getUser(tmp.getAid());
                List<Courses> courses = userUtil.getAll_Courses();
                request.setAttribute("listCourses", courses);
                request.setAttribute("user_info", user);
                String[] a = user.getFull_name().split(" ");
                String b = a[a.length - 1];
                HttpSession session = request.getSession(true);
                session.setAttribute("name", b);
                session.setAttribute("uid", user.getUid());
                session.setAttribute("aid", user.getAid());
                RequestDispatcher dispatcher = request.getRequestDispatcher("/UserPage.jsp");
                dispatcher.forward(request, response);
            }
        } else {
            request.setAttribute("errorString", "Username or password is incorrect");
            RequestDispatcher dispatcher = request.getRequestDispatcher("/invalidLogin.jsp");
            dispatcher.forward(request, response);
        }
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : Account(Model.Account) User(Model.User) SQLException(java.sql.SQLException) HttpSession(javax.servlet.http.HttpSession) Courses(Model.Courses) RequestDispatcher(javax.servlet.RequestDispatcher) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) SQLException(java.sql.SQLException)

Aggregations

Account (com.google.api.services.adsense.v2.model.Account)5 Account (Model.Account)4 Account (model.Account)4 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 RequestDispatcher (javax.servlet.RequestDispatcher)3 HandleString (util.HandleString)3 Courses (Model.Courses)2 IOException (java.io.IOException)2 Connection (java.sql.Connection)2 User (model.User)2 Chapter (Model.Chapter)1 Instructor (Model.Instructor)1 User (Model.User)1 FileDataStoreFactory (com.google.api.client.util.store.FileDataStoreFactory)1 Adsense (com.google.api.services.adsense.v2.Adsense)1 AdClient (com.google.api.services.adsense.v2.model.AdClient)1 AdUnit (com.google.api.services.adsense.v2.model.AdUnit)1 CustomChannel (com.google.api.services.adsense.v2.model.CustomChannel)1