private static OseeServerInfoMutable createOseeServerInfo( Log logger, ApplicationServerDataStore dataStore, Set<String> defaultVersions) { String serverAddress = "127.0.0.1"; try { serverAddress = InetAddress.getLocalHost().getCanonicalHostName(); } catch (UnknownHostException ex) { // } int port = OseeServerProperties.getOseeApplicationServerPort(); String checkSum = "-1"; try { String address = String.format("%s:%s", serverAddress, port); ByteArrayInputStream inputStream = new ByteArrayInputStream(address.getBytes("UTF-8")); checkSum = ChecksumUtil.createChecksumAsString(inputStream, ChecksumUtil.MD5); } catch (Exception ex) { logger.error(ex, "Error generating application server id"); } OseeServerInfoMutable toReturn = new OseeServerInfoMutable( checkSum, serverAddress, port, new String[0], GlobalTime.GreenwichMeanTimestamp(), false); toReturn.setVersions(defaultVersions); return toReturn; }
private void loadAttributeWasValues( Branch sourceBranch, TransactionRecord transactionId, Set<Integer> artIds, IProgressMonitor monitor, Map<Integer, ChangeBuilder> attributesWasValueCache, boolean hasBranch) throws OseeCoreException, OseeDataStoreException { if (!artIds.isEmpty()) { int sqlParamter; // Will either be a branch id or transaction id Branch wasValueBranch; String sql; if (hasBranch) { wasValueBranch = sourceBranch; sql = ClientSessionManager.getSql(OseeSql.CHANGE_BRANCH_ATTRIBUTE_WAS); sqlParamter = wasValueBranch.getId(); } else { wasValueBranch = transactionId.getBranch(); sql = ClientSessionManager.getSql(OseeSql.CHANGE_TX_ATTRIBUTE_WAS); sqlParamter = transactionId.getId(); } int queryId = ArtifactLoader.getNewQueryId(); Timestamp insertTime = GlobalTime.GreenwichMeanTimestamp(); List<Object[]> datas = new LinkedList<Object[]>(); IOseeStatement chStmt = ConnectionHandler.getStatement(); try { // insert into the artifact_join_table for (int artId : artIds) { datas.add( new Object[] { queryId, insertTime, artId, wasValueBranch.getId(), SQL3DataType.INTEGER }); } ArtifactLoader.insertIntoArtifactJoin(datas); chStmt.runPreparedQuery(sql, sqlParamter, queryId); int previousAttrId = -1; while (chStmt.next()) { int attrId = chStmt.getInt("attr_id"); if (previousAttrId != attrId) { String wasValue = chStmt.getString("was_value"); if (attributesWasValueCache.containsKey(attrId) && attributesWasValueCache.get(attrId) instanceof AttributeChangeBuilder) { AttributeChangeBuilder changeBuilder = (AttributeChangeBuilder) attributesWasValueCache.get(attrId); if (changeBuilder.getArtModType() != ModificationType.NEW) { if (changeBuilder.getModType() != ModificationType.DELETED && changeBuilder.getModType() != ModificationType.ARTIFACT_DELETED) { changeBuilder.setModType(ModificationType.MODIFIED); } changeBuilder.setWasValue(wasValue); } } previousAttrId = attrId; } } } finally { ArtifactLoader.clearQuery(queryId); chStmt.close(); } if (getMonitor() != null) { monitor.worked(12); } } }