Tabnine Logo
Contributions
Code IndexAdd Tabnine to your IDE (free)

How to use
Contributions
in
ca.carleton.gcrc.contributions

Best Java code snippets using ca.carleton.gcrc.contributions.Contributions (Showing top 10 results out of 315)

origin: ca.carleton.gcrc/nunaliit2-contributions

  static public Contributions createContibutionHandler(ServletContext servletContext, Connection connection) {
    Contributions contributions = null;
    
    // Load up contribution properties file....
    Properties props = new Properties();
    {
      if( null != servletContext ) {
        Object propertiesObj = servletContext.getAttribute(PROPERTIES_SERVLET_ATTRIB_NAME);
        if( null != propertiesObj
         && propertiesObj instanceof Properties ) {
          props = (Properties)propertiesObj;
        }
      }
    }
    
    try {
      contributions = new Contributions(props, connection);
    } catch (Exception e) {
      logger.error("Contributions table problem - check that properties file definitions match database schema:", e);
      return(null);
    }

    return(contributions);
  }
}
origin: ca.carleton.gcrc/nunaliit2-contributions

private void readProperties(Properties props) throws Exception {
  tableName = props.getProperty(PROPERTIES_KEY_TABLE_NAME, DEFAULT_TABLE_NAME);
  idColumnName = props.getProperty(PROPERTIES_KEY_ID_COLUMN_NAME, DEFAULT_ID_COLUMN_NAME);
  idSequenceName = props.getProperty(PROPERTIES_KEY_ID_SEQUENCE_NAME, DEFAULT_ID_SEQUENCE_NAME);
  
  String serverFieldList = props.getProperty(PROPERTIES_KEY_SERVER_SUPPORTED_COLUMNS, DEFAULT_SERVER_SUPPORTED_COLUMNS);
  String clientFieldList = props.getProperty(PROPERTIES_KEY_CLIENT_SIDE_COLUMNS, DEFAULT_CLIENT_SIDE_COLUMNS);
  createServerSupportedAndClientSideLists(serverFieldList, clientFieldList);
  allFieldsInDb(serverFieldList, true); // verify all fields in prop lists accounted for in db - throw exception otherwise
  allFieldsInDb(clientFieldList, false);
  
  if (serverSupported.includes(idColumnName)) { // mark that column as auto incremented
    serverSupported.setAutoIncrementSequence(idColumnName, idSequenceName);
  } else {
    throw new Exception(idColumnName + " must be included in the serverSupported field list.");
  }
      
  deleteSqlStatement = "DELETE FROM \""+tableName+"\" WHERE \""+idColumnName+"\" = ?;";
}

origin: ca.carleton.gcrc/nunaliit2-contributions

protected void performDelete(HttpServletRequest request, HttpServletResponse response) throws Exception {
  String[] ids = request.getParameterValues("id");
  String[] placeIds = request.getParameterValues("placeId");
  
  if( null == ids || ids.length < 1 ) {
    throw new Exception("Parameter 'id' not provided");
  }
  if( ids.length > 1 ) {
    throw new Exception("Parameter 'id' provided multiple times");
  }
  
  if( null == placeIds ) {
    placeIds = new String[0];
  }
  if( placeIds.length > 1 ) {
    throw new Exception("Parameter 'place_id' provided multiple times");
  }
  
  contributions.deleteContribution(ids[0], (placeIds.length > 0 ? placeIds[0] : null));
  
  JSONObject result = new JSONObject();
  result.put("id", ids[0]);
  if( placeIds.length > 0 ) {
    result.put("place_id", placeIds[0]);
  }
  sendJsonResponse(response, result);
}

origin: ca.carleton.gcrc/nunaliit2-contributions

for (int loop=0; loop<count; ++loop) {
  String columnName = rsmd.getColumnName(loop+1);
  boolean isServerSupported = isColumnNameInList(columnName, serverFields);
  boolean isClientSide = isColumnNameInList(columnName, clientFields);
origin: ca.carleton.gcrc/nunaliit2-onUpload

public void performDatabaseInsert(UploadedFileInfo fileInfo, Contributions cont) throws Exception {
  logger.info("Inserting contribution for user id: "+(userPrincipal==null?"unknown":userPrincipal.getName()));
  createServerGeneratedFields(fileInfo, cont, false);
  cont.insert(parameters);
}

origin: ca.carleton.gcrc/nunaliit2-contributions

protected void performFromName(HttpServletRequest request, HttpServletResponse response) throws Exception {
  String[] names = request.getParameterValues("name");
  
  if( null == names || names.length < 1 ) {
    throw new Exception("Parameter 'name' not provided");
  }
  if( names.length > 1 ) {
    throw new Exception("Parameter 'name' provided multiple times");
  }
  
  if (null != contributions) {
    JSONObject result = contributions.fromName(names[0], userRepository);
    sendJsonResponse(response, result);
  } else {
    throw new Exception("Contribution record access requests can not be fulfill because of failed initialization - look for earlier exceptions.");
  }
}

origin: ca.carleton.gcrc/nunaliit2-contributions

public Contributions(Properties props, Connection connection) throws Exception {
  this.connection = connection;
  serverSupported = new ContributionServerSupportedFieldsImpl();
  clientSide = new ContributionClientSideFieldsImpl();
  readProperties(props);
}
origin: ca.carleton.gcrc/nunaliit2-contributions

  public JSONObject fromName(String intPlaceId, UserRepository userRepository) throws Exception {
    String queryString = "SELECT " + serverSupported.getFieldNamesList();
    String clientFieldList = clientSide.getFieldNamesList();
    
    /*
     * Assume there must be serverSupported fields but allow for no clientSide fields...
     */
    if (clientFieldList != "") {
      queryString += "," + clientFieldList;
    }
    queryString += " FROM " + tableName + " WHERE place_id=?;";
    
    PreparedStatement stmt = connection.prepareStatement(queryString);
    serverSupported.writeToPreparedStatement(stmt, "place_id", 1, intPlaceId);
//logger.info(stmt.toString());
    JSONArray contributions = executeContribSelectToJson(stmt, userRepository);
    JSONObject result = new JSONObject();
    result.put("contributions", contributions);
    return(result);
  }
  
origin: ca.carleton.gcrc/nunaliit2-contributions

public void init(ServletConfig config) throws ServletException {
  super.init(config);
  try {
    connections = JdbcConnections.connectionsFromServletContext(config.getServletContext());
    connection = connections.getDb();
  } catch (Exception e) {
    throw new ServletException("Error while connecting to database",e);
  }
  
  userRepository = UserRepositorySingleton.getSingleton();
  
  contributions = ContributionsUtils.createContibutionHandler(config.getServletContext(), connection);
  if (null == contributions) {
    return;
  }
  
  try {
    ContributionComet contComet = new ContributionCometImpl(config.getServletContext());
    contributions.setContributionComet( contComet );
  } catch(Exception e) {
    logger.error("Comet not available for contributions", e);
  }
}
origin: ca.carleton.gcrc/nunaliit2-contributions

boolean first = true;
for (int i=0; i<fullList_serverFields.length; i++) {
  if (!isColumnNameInList(fullList_serverFields[i], dontChange_serverSupported)) {
    if (fieldPairs.containsKey(fullList_serverFields[i])) {
      if (first) {
ca.carleton.gcrc.contributionsContributions

Most used methods

  • <init>
  • allFieldsInDb
  • createServerSupportedAndClientSideLists
  • deleteContribution
  • executeContribSelectToJson
  • fromName
  • insert
  • isColumnNameInList
  • readProperties
  • setContributionComet
  • update
  • update

Popular in Java

  • Start an intent from android
  • putExtra (Intent)
  • getExternalFilesDir (Context)
  • setContentView (Activity)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Option (scala)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now